a c @s@ddlZddlZddlZddlmZddlmZddlmZm Z m Z m Z m Z m Z mZmZddlZddlmZmZddlmZddlmZmZmZddlmZdd lmZmZmZdd l m!Z!dd l"m#Z#erd d l$m%Z%ee&e'dfe(dddZ)e ee ee efe ee ee efe'fe e'e fdddZ*e'e e'dddZ+dddeddfe'e e e e e'efe e ee(efe ee ee e'ed ddZ,ddee e e ee efedddZ-e'e'e'e'dd d!Z.d"e'd#d$d%Z/e e e fe e e fdd&d'd(Z0eeefeeefeeefd)d*d+Z1dS),N) is_dataclass)Enum) TYPE_CHECKINGAnyDictOptionalSetTypeUnioncast)DefaultPlaceholder DefaultType) REF_PREFIX) BaseConfig BaseModel create_model) Validator) FieldInfo ModelField UndefinedType)model_process_schema)lenient_issubclass)APIRoute) status_codereturncCs2|dur dS|dvrdSt|}|dkp.|dv S)NT>Z4XXZ3XXdefaultZ1XXZ5XXZ2XX>i0)int)rZcurrent_status_coder Z/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/fastapi/utils.pyis_body_allowed_for_status_codes r") flat_modelsmodel_name_maprcCs^i}|D]P}t||td\}}}||||}d|vrP|ddd|d<|||<q|S)N)r$Z ref_prefix description r)rrupdatesplit)r#r$Z definitionsmodelZm_schemaZ m_definitionsZm_nested_modelsZ model_namer r r!get_model_definitions&s   r*)pathrcCsttd|S)Nz{(.*?)})setrefindall)r+r r r!get_path_param_names8sr/T) nametype_class_validatorsrrequired model_config field_infoaliasrc Csf|pi}|pt}tjt|||||||d}z ||dWSty`tjd|ddYn0dS)zB Create a new response field. Raises if type_ is invalid. )r0r1r2rr3r4r6)r5z2Invalid args for response field! Hint: check that aY is a valid Pydantic field type. If you are using a return type annotation that is not a valid Pydantic field (e.g. Union[Response, dict, None]) you can disable generating the response model from the type annotation with the path operation decorator parameter response_model=None. Read more: https://fastapi.tiangolo.com/tutorial/response-model/N)r functoolspartialr RuntimeErrorfastapi exceptionsZ FastAPIError) r0r1r2rr3r4r5r6Zresponse_fieldr r r!create_response_field<s,     r< cloned_types)fieldr>rcsRdur i|j}t|r*t|dr*|j}|}t|trttt|}|}|durt |j |d}||<|j D]}t |d|j |j<qxt|j|d}|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|jrfdd|jD|_|jrt |jd|_|j|_|j|_|j|_|j|_|j|_| |S)N__pydantic_model__)__base__r=)r0r1csg|]}t|dqS)r=)create_cloned_field).0Z sub_fieldr=r r! sz'create_cloned_field..)!r1rhasattrr@rrr r getr__name__Z __fields__valuesrBr0r<Z has_aliasr6r2rr3r4r5 allow_noneZvalidate_alwaysZ sub_fieldsZ key_fieldZ validatorsZpre_validatorsZpost_validatorsZ parse_jsonshapeZpopulate_validators)r?r> original_typeZuse_typefZ new_fieldr r=r!rBesR   rB)r0r+methodrcCs:tjdtdd||}tdd|}|d|}|S)Nzrfastapi.utils.generate_operation_id_for_path() was deprecated, it is not used internally, and will be removed soon) stacklevel\W_)warningswarnDeprecationWarningr-sublower)r0r+rM operation_idr r r!generate_operation_id_for_pathsrXr)routercCsB|j|j}tdd|}|js$J|dt|jd}|S)NrPrQr)r0Z path_formatr-rUmethodslistrV)rYrWr r r!generate_unique_ids   r\) main_dict update_dictrcCs|D]z\}}||vr@t||tr@t|tr@t|||q||vrzt||trzt||trz||||||<q|||<qdS)N)items isinstancedictdeep_dict_updater[)r]r^keyvaluer r r!rbs    rb) first_item extra_itemsrcGs*|f|}|D]}t|ts|Sq|S)z Pass items or `DefaultPlaceholder`s by descending priority. The first one to _not_ be a `DefaultPlaceholder` will be returned. Otherwise, the first item (a `DefaultPlaceholder`) will be returned. )r`r )rerfr_itemr r r!get_value_or_defaults   rh)2r7r-rRZ dataclassesrenumrtypingrrrrrr r r r:Zfastapi.datastructuresr r Zfastapi.openapi.constantsrZpydanticrrrZpydantic.class_validatorsrZpydantic.fieldsrrrZpydantic.schemarZpydantic.utilsrZroutingrrstrboolr"r*r/r<rBrXr\rbrhr r r r!sj  (        , 3 "