a cxI@sUddlZddlZddlZddlmZddlmZmZm Z m Z m Z m Z m Z mZmZmZddlmZddlmZddlmZddlmZmZddlmZdd lmZmZdd lm Z dd l!m"Z"m#Z#dd l$m%Z%dd l&m'Z'm(Z(m)Z)m*Z*ddl+m,Z,ddl-m.Z.m/Z/ddl0m1Z1m2Z2m3Z3ddl4m5Z5ddl6m7Z7ddl8m9Z9ddl:m;Z;dddddddiddigiddddd ddd!gd!d"Zee?e?fe@d/<ee ee?efe ee?effd0d1d2ZAe e.eeee,eefe?fe ee?efd3d4d5ZBe e.eeee,eefe?fe ee?efd6d7d8ZCejDe?e?d9d:d;ZEejDe?e?d9dd?d@ZGejDeeHe?fe e?e ee?efee?efee?effdAdBdCZIe e9e eee,eefdDdEdFZJdGdddddddHe?e?e?e e?e e9e e ee?efe e ee?ee?effe e?e ee?ee?effe ee?ee?effee?efdI dJdKZKdS)LN)Enum) AnyDictListOptionalSequenceSetTupleTypeUnioncast)routing)DefaultPlaceholder) Dependant)get_flat_dependantget_flat_params)jsonable_encoder)METHODS_WITH_BODY REF_PREFIX)OpenAPI)BodyParam)Response)deep_dict_updategenerate_operation_id_for_pathget_model_definitionsis_body_allowed_for_status_code) BaseModel) ModelField Undefined) field_schemaget_flat_models_from_fieldsget_model_name_map)lenient_issubclass) JSONResponse) BaseRoute)HTTP_422_UNPROCESSABLE_ENTITYValidationErrorobjectZLocationarrayZanyOftypestringinteger)titler*itemsMessage)r-r*z Error Type)locmsgr*)r-r* propertiesrequiredHTTPValidationErrorZdetailZDetail$ref)r-r*r2Z InformationZSuccessZ Redirectionz Client Errorz Server ErrorzDefault Response)Z1XXZ2XXZ3XX4XXZ5XXDEFAULTstatus_code_ranges)flat_dependantreturncCsNi}g}|jD]6}t|jjddd}|jj}|||<|||jiq||fS)NTZby_aliasZ exclude_none)Zsecurity_requirementsrZsecurity_schememodelZ scheme_nameappendZscopes)r9security_definitionsoperation_securityZsecurity_requirementZsecurity_definitionZ security_namer@b/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/fastapi/openapi/utils.py get_openapi_security_definitionsGs rB)all_route_paramsmodel_name_mapr:c Csg}|D]}|j}tt|}|js$q|j|jj|jt||t ddd}|j rX|j |d<|j rnt |j |d<n|j tkrt |j |d<|jr|j|d<||q|S)NrDZ ref_prefixr)nameinr3schema descriptionexamplesexample deprecated) field_infor rinclude_in_schemaaliasZin_valuer3r rrIrJrrKrrLr=)rCrD parametersparamrMZ parameterr@r@rA get_openapi_operation_parametersXs2     rS) body_fieldrDr:c Cs|sdSt|tsJt||td\}}}tt|j}|j}|j}i}|rR||d<d|i}|j rpt |j |d<n|j t krt |j |d<||i|d<|S)NrEr3rHrJrKcontent) isinstancerr rr rrM media_typer3rJrrKr) rTrDZ body_schema_rMZrequest_media_typer3request_body_oaiZrequest_media_contentr@r@rA"get_openapi_operation_request_bodyws&    rZ)routemethodr:cCs2tjdtdd|jr|jS|j}t|j||dS)Nzqfastapi.openapi.utils.generate_operation_id() was deprecated, it is not used internally, and will be removed soon) stacklevel)rFpathr\)warningswarnDeprecationWarning operation_id path_formatrrF)r[r\r_r@r@rAgenerate_operation_idsrecCs|jr |jS|jddS)NrX )summaryrFreplacer-r[r\r@r@rAgenerate_operation_summarysrj)r[r\ operation_idsr:cCsi}|jr|j|d<t||d|d<|jr4|j|d<|jp>|j}||vrd|d|jj}t|jdid}|r|d |7}t || |||d <|j r|j |d <|S) NtagsrirgrIzDuplicate Operation ID z for function __globals____file__z at Z operationIdrL) rlrjrIrcZ unique_idZendpoint__name__getattrgetr`raaddrL)r[r\rk operationrcmessage file_namer@r@rAget_openapi_operation_metadatas*       rv)r[rDrkr:c)s0i}i}i}|jdusJdt|jtr4|jj}n|j}|sFJd|j}|jr&|jD]}t|||dg} t|j dd} t | d\} } | r dg | | r| | t|j } t| |d}| || rd d | D}d d | D}| |t|d <|tvr4t|j|d }|r4|d<|jri}|jD]8}t|tjrFt|||d\}}}|j|i||j<qF|d<|jdurt|j}n:t|j}|j !d}|durt|j"t#rt|j"}|j$ di |id<|rft%|jrfddi}t&|t'r>|j(r:t)|j(|t*d\}}}ni}| di |i di |id<|j+r di}|j+,D] \}}|-}|.ddt|/} | dkrd} | | i}!t|t0sJd|j1!|}"d}#|"r6t)|"|t*d\}#}}|pd}$| di |$i di}%t2|%|#t3!t|/pZt4j5j+!t#|}&|!dp||!!dp||&p|d}'t2|!||'|!d<qtt6}(| s|jrt7fdd |(d!dfDsd"ddd#t*d$iiid%d|(<d&|vr| t8t9d'|j:rt2|j:||;<qZ|||fS)(NzMethods must be a listz.A response class is needed to generate OpenAPI)r[r\rkT)Z skip_repeats)r9security)rCrDcSsi|]}|d|df|qS)rGrFr@.0rRr@r@rA sz$get_openapi_path..cSs(i|] }|dr|d|df|qS)r3rGrF)rqrxr@r@rArzs rQ)rTrDZ requestBodyr[rDrk callbacks status_code responsesrIr*r+rErUrHr<r7defaultz%An additional response must be a dictzapplication/jsonzAdditional Responsecsg|]}|dvqS)r~r@)rystatusrsr@rA Osz$get_openapi_path..r6zValidation Errorr5r4)rIrUr')r'r4)<methodsrVresponse_classrrPrWrNrvr dependantrB setdefaultextendupdaterrSlistvaluesrrZrTr|r APIRouteget_openapi_pathr_rFr}strinspect signature__init__rQrqrintZresponse_descriptionrr#r$response_fieldr rr~r.copypopupperdictresponse_fieldsrr8httpclientr&anyvalidation_error_definition$validation_error_response_definitionZ openapi_extralower))r[rDrkr_security_schemes definitionsZcurrent_response_classZroute_response_media_typer\rQr9r>r?rCZoperation_parametersZall_parametersZrequired_parametersrYr|callbackZcb_pathZcb_security_schemesZcb_definitionsr}Zresponse_signatureZstatus_code_paramZresponse_schemarXZoperation_responsesZadditional_status_codeZadditional_responseprocess_responseZstatus_code_keyZopenapi_responsefieldZadditional_field_schemarWZadditional_schemaZ status_textrIZhttp422r@rrArs@                                    r)routesr:cCsg}g}g}t}|D]}t|ddrt|tjr|jrXt|jtsLJd||j|jrj||j|j r| |j |j r|t |j O}t|j}| |q|t|||tdB}|S)NrNz'A request body must be a Pydantic Field)Z known_models)setrprVr rrTrr=rrrrr|get_flat_models_from_routesrrr!)rZbody_fields_from_routesZresponses_from_routesZrequest_fields_from_routesZcallback_flat_modelsr[params flat_modelsr@r@rAris8     rz3.0.2)openapi_versionrIrlserversterms_of_servicecontact license_info) r-versionrrIrrlrrrrr:c sD||d} |r|| d<|r"|| d<|r.|| d<| r:| | d<|| d} |rP|| d<i} i} t}t|}t|}t||d|D]h}t|tjr~t|||d }|r~|\}}}|r| |j i ||r| d i ||r~ |q~rfd d t D| d <| r| | d<| | d<|r,|| d<t t fi| dddS)N)r-rrIZtermsOfServicerlicense)Zopenapiinfor)rrDr{ZsecuritySchemescsi|]}||qSr@r@)rykrr@rArzzget_openapi..Zschemas componentspathsrlTr;)rrr"rrVr rrrrdrsortedrr)r-rrrIrrlrrrrroutputrrrkrrDr[resultr_rZpath_definitionsr@rrA get_openapisV      r)L http.clientrrr`enumrtypingrrrrrrr r r r Zfastapir Zfastapi.datastructuresrZfastapi.dependencies.modelsrZfastapi.dependencies.utilsrrZfastapi.encodersrZfastapi.openapi.constantsrrZfastapi.openapi.modelsrZfastapi.paramsrrZfastapi.responsesrZ fastapi.utilsrrrrZpydanticrZpydantic.fieldsrrZpydantic.schemar r!r"Zpydantic.utilsr#Zstarlette.responsesr$Zstarlette.routingr%Zstarlette.statusr&rrr8r__annotations__rBrSrZrrerjrvr*rrrr@r@r@rAs  0                 !    $ + $