
     @gW                        U d dl Zd dlZd dlZd dlmZmZmZmZm	Z	m
Z
mZmZmZmZ d dlmZ d dlmZmZmZmZmZmZmZmZ d dlmZ d dlmZ d dlmZm Z  d dl!m"Z" d d	l#m$Z$m%Z%m&Z& d d
l'm(Z( d dl)m*Z*m+Z+ d dl,m-Z- d dl.m/Z/ d dl0m1Z1m2Z2m3Z3 d dl4m5Z5 d dl6m7Z7 d dl8m9Z9 d dl:m;Z; dddddddiddigiddddddddg dd Z<d!dd"d#dd$e%dz   idid%Z=d&d'd(d)d*d+d,Z>ee?e?f         e@d-<   d.ed/eee?ef         eee?ef                  f         fd0ZAd1d2d3e	e         d4ed5e/d6eeee;d7         f         ef         d8eBd/eee?ef                  fd9ZCd1d2d:ee         d4ed5e/d6eeee;d7         f         ef         d8eBd/eee?ef                  fd;ZDd<ejE        d=e?d/e?fd>ZFd<ejE        d=e?d/e?fd?ZGd<ejE        d=e?d@e
e?         d/ee?ef         fdAZHd1d2d<ejE        d@e
e?         d4ed5e/d6eeee;d7         f         ef         d8eBd/eee?ef         ee?ef         ee?ef         f         fdBZIdCe	e7         d/ee         fdDZJdEddddddddd1dF
dGe?dHe?dIe?dJee?         dKee?         dCe	e7         dLee	e7                  dMeeee?ef                           dNeeee?ee?ef         f                           dOee?         dPeee?ee?ef         f                  dQeee?ee?ef         f                  d8eBd/ee?ef         fdRZKdS )S    N)
AnyDictListOptionalSequenceSetTupleTypeUnioncast)routing)GenerateJsonSchemaJsonSchemaValue
ModelField	Undefinedget_compat_model_name_mapget_definitionsget_schema_from_model_fieldlenient_issubclass)DefaultPlaceholder)	Dependant)get_flat_dependantget_flat_params)jsonable_encoder)METHODS_WITH_BODY
REF_PREFIXREF_TEMPLATE)OpenAPI)BodyParam)Response)ModelNameMap)deep_dict_updategenerate_operation_id_for_pathis_body_allowed_for_status_code)JSONResponse)	BaseRoute)HTTP_422_UNPROCESSABLE_ENTITY)LiteralValidationErrorobjectLocationarrayanyOftypestringinteger)titler/   itemsMessage)r2   r/   z
Error Type)locmsgr/   )r2   r/   
propertiesrequiredHTTPValidationErrordetailDetail$ref)r2   r/   r7   InformationSuccessRedirectionzClient ErrorzServer ErrorzDefault Response)1XX2XX3XX4XX5XXDEFAULTstatus_code_rangesflat_dependantreturnc                     i }g }| j         D ]K}t          |j        j        dd          }|j        j        }|||<   |                    ||j        i           L||fS )NTby_aliasexclude_none)security_requirementsr   security_schememodelscheme_nameappendscopes)rG   security_definitionsoperation_securitysecurity_requirementsecurity_definitionsecurity_names         I/var/www/piapp/venv/lib/python3.11/site-packages/fastapi/openapi/utils.py get_openapi_security_definitionsrY   I   s      . D P P. 06
 
 

 -<H.A]+!!=2F2M"NOOOO!333    T)separate_input_output_schemasall_route_paramsschema_generatormodel_name_mapfield_mapping)
validationserializationr[   c                    g }| D ]}|j         }t          t          |          }|j        s&t	          |||||          }|j        |j        j        |j        |d}	|j	        r
|j	        |	d<   |j
        rt          |j
                  |	d<   n'|j        t          k    rt          |j                  |	d<   |j        r
|j        |	d<   |                    |	           |S )Nfieldr]   r^   r_   r[   )nameinr8   schemadescriptionexamplesexample
deprecated)
field_infor   r    include_in_schemar   aliasin_valuer8   rh   openapi_examplesr   rj   r   rk   rQ   )
r\   r]   r^   r_   r[   
parametersparamrl   param_schema	parameters
             rX    get_openapi_operation_parametersrv   Z   s    J! % %%
%,,
+ 	2-)'*G
 
 
 K.&"	
 
	 ! 	>'1'=Im$& 	H$4Z5P$Q$QIj!!9,,#3J4F#G#GIi   	<&0&;Il#)$$$$rZ   
body_fieldc                 h   | sd S t          | t                    sJ t          | ||||          }t          t          | j                  }|j        }| j        }i }	|r||	d<   d|i}
|j        rt          |j                  |
d<   n'|j
        t          k    rt          |j
                  |
d<   ||
i|	d<   |	S )Nrc   r8   rg   ri   rj   content)
isinstancer   r   r   r   rl   
media_typer8   rq   r   rj   r   )rw   r]   r^   r_   r[   body_schemarl   request_media_typer8   request_body_oairequest_media_contents              rX   "get_openapi_operation_request_bodyr      s      tj*------)%#&C  K dJ122J#."H') 0'/$-5{,C" P,<'-
 -
j)) 
	y	(	(+;J<N+O+Oi(#57L"MYrZ   routemethodc                     t          j        dt          d           | j        r| j        S | j        }t          | j        ||          S )Nzqfastapi.openapi.utils.generate_operation_id() was deprecated, it is not used internally, and will be removed soon   
stacklevel)re   pathr   )warningswarnDeprecationWarningoperation_idpath_formatr$   re   )r   r   r   s      rX   generate_operation_idr      s]     M	>	     "!!!D)uzVTTTTrZ   c                 x    | j         r| j         S | j                            dd                                          S )N_ )summaryre   replacer2   r   r   s     rX   generate_operation_summaryr      s8    } }:c3''--///rZ   operation_idsc                    i }| j         r
| j         |d<   t          | |          |d<   | j        r
| j        |d<   | j        p| j        }||v r]d| d| j        j         z   }t          | j        di                               d          }|r|d	| z  }t          j
        |d
           |                    |           ||d<   | j        r
| j        |d<   |S )Ntagsr   r   rh   zDuplicate Operation ID z for function __globals____file__z at    r   operationIdrk   )r   r   rh   r   	unique_idendpoint__name__getattrgetr   r   addrk   )r   r   r   	operationr   message	file_names          rX   get_openapi_operation_metadatar      s    !#Iz '!J	&5E&QQQIi 5#(#4	- %8L}$$BlBBB(*+ 	 ENM2>>BB:NN	 	*)i)))Gg!,,,,l###+Im 3"'"2	,rZ   c           
        + i }i }i }| j         
J d            t          | j        t                    r| j        j        }	n| j        }	|	s
J d            |	j        }
| j        r| j         D ]}t          | ||          +g }t          | j	        d          }t          |          \  }}|r)+                    dg                               |           |r|                    |           t          | j	                  }t          |||||          }|                    |           |rQd	 |D             }d
 |D             }|                    |           t!          |                                          +d<   |t$          v r t'          | j        ||||          }|r|+d<   | j        rUi }| j        D ]F}t          |t,          j                  r*t1          ||||||          \  }}}|j        |i||j        <   G|+d<   | j        t9          | j                  }nct;          j        |	j                  }|j         !                    d          }|.t          |j"        tF                    rt9          |j"                  }| j$        +                    di                               |i           d<   |
rtK          | j                  rddi}tM          |	tN                    r#| j(        rtS          | j(        ||||          }ni }|+                    di                               |i                               di                               |
i           d<   | j*        r+                    di           }| j*        +                                D ]\  }} | ,                                }!|!-                    dd            t9          |          .                                }"|"dk    rd}"|                    |"i           }#t          |!t^                    s
J d            | j0        !                    |          }$d }%|$rftS          |$||||          }%|
pd}&|!                    di                               |&i                               di           }'tc          |'|%           td          !                    t9          |          .                                          p0tf          j4        j*        !                    tG          |                    }(|!!                    d          p|#!                    d          p|(pd})tc          |#|!           |)|#d<   t9          tj                    }*|s| j        r`tm          +fd|*ddfD                       sBd ddd!tn          d"z   iiid#+d         |*<   d$|vr"|                    tp          tr          d%           | j:        rtc          +| j:                   +||;                                <   |||fS )&NzMethods must be a listz.A response class is needed to generate OpenAPI)r   r   r   T)skip_repeats)rG   security)r\   r]   r^   r_   r[   c                 0    i | ]}|d          |d         f|S )rf   re    .0rs   s     rX   
<dictcomp>z$get_openapi_path.<locals>.<dictcomp>  s4     " " "<AU4[%-0%" " "rZ   c                 Z    i | ](}|                     d           |d         |d         f|)S )r8   rf   re   )r   r   s     rX   r   z$get_openapi_path.<locals>.<dictcomp>  sI     ' ' 'yy,,'4[%-0%' ' 'rZ   rr   )rw   r]   r^   r_   r[   requestBodyr   r   r]   r^   r_   r[   	callbacksstatus_code	responsesrh   r/   r0   rc   ry   rg   rO   rE   defaultz%An additional response must be a dictzapplication/jsonzAdditional Responsec              3   ,   K   | ]}|d          v V  dS )r   Nr   )r   statusr   s     rX   	<genexpr>z#get_openapi_path.<locals>.<genexpr>~  sI       B B )K00B B B B B BrZ   rC   zValidation Errorr<   r9   )rh   ry   r*   )r*   r9   )<methodsrz   response_classr   rp   r{   rm   r   r   	dependantrY   
setdefaultextendupdater   rv   listvaluesr   r   rw   r   r   APIRouteget_openapi_pathr   re   r   strinspect	signature__init__rr   r   r   intresponse_descriptionr%   r   r&   response_fieldr   r   r3   copypopupperdictresponse_fieldsr#   rF   httpclientr(   anyr   validation_error_definition$validation_error_response_definitionopenapi_extralower),r   r   r]   r^   r_   r[   r   security_schemesdefinitionscurrent_response_classroute_response_media_typer   rr   rG   rS   rT   r\   operation_parametersall_parametersrequired_parametersr~   r   callbackcb_pathcb_security_schemescb_definitionsr   response_signaturestatus_code_paramresponse_schemaoperation_responsesadditional_status_codeadditional_responseprocess_responsestatus_code_keyopenapi_responserd   additional_field_schemar{   additional_schemastatus_textrh   http422r   s,                                              @rX   r   r      s    D')"$K=$$&>$$$%&(:;; 6161E1K!&!5!SS#SSSS/E/P g-m f	- f	-F6F-  I 02J/dSSSN7W-8 8 84 "4 " P$$Z44;;<NOOO# > ''(<===.u??#C!1!1-+.K$ $ $  2333 H" "EO" " "' '!+' ' '# %%&9:::*.~/D/D/F/F*G*G	,'***#E$/%5#1"/2O$ $ $  $ @/?Im, 3	 % L LH!(G,<== L
 -"**7-=+9*7:W  	#/* 5=M73K	(-0)2	+& ,!%"344 &-%67M7V%W%W"$6$A$E$Em$T$T!$0!"3";SAA E&)*;*C&D&D *   b11<<["MM ) $-L!. . $ $*8"4%&<lKK 
-+ 	-*E"'"6-=+9*7:W+ + + +-
 $	 $$["55@@ *Y++JJ7PRT,U,U
  ,B&/&:&:;&K&K# _**,,*B *B *'':'?'?'A'A$$(($777&)*@&A&A&G&G&I&IO&)33*3':'E'E'( ($ &($  ? ?>? ? ? "1556LMMEHL+ U2M"'-=+9*7:W3 3 3/ &?%TBT
,77	2FF'Z
B77'Z"55 *
 )):<STTT1C1G1G23399;;2 2 2P.2237M3N3NOO   ),,];; 1+//>>1&1 1	   %%57GHHH6A$]33788G  E$4 c B B B B&y9B B B ? ? 
 $6*$vz<Q/Q&R- 3 3	+&w/ %K77&&/J3W    " A E,?@@@#,D  !;..rZ   routesc                    g }g }g }g }| D ]}t          |dd           r
t          |t          j                  r|j        r>t          |j        t
                    s
J d            |                    |j                   |j        r|                    |j                   |j        r,|	                    |j        
                                           |j        r'|	                    t          |j                             t          |j                  }|	                    |           !|t          ||z   |z             z   }|S )Nrm   z'A request body must be a Pydantic Field)r   rz   r   r   rw   r   rQ   r   r   r   r   r   get_fields_from_routesr   r   r   )r   body_fields_from_routesresponses_from_routesrequest_fields_from_routescallback_flat_modelsr   paramsflat_modelss           rX   r   r     s~    13.035-/ 6 65-t44 	67#:
 :
 	6  A!$j  = =<= = = (..u/?@@@# C%,,U-ABBB$ M%,,U-B-I-I-K-KLLL U$++,B5?,S,STTT$U_55F&--f555&"77:TT* * K rZ   z3.1.0)
openapi_versionr   rh   webhooksr   serversterms_of_servicecontactlicense_infor[   r2   versionr   r   rh   r   r   r   r   r   r   c           	         | |d}|r||d<   |r||d<   |	r|	|d<   |
r|
|d<   |r||d<   ||d}|r||d<   i }i }i }t                      }t          t          |pg           t          |pg           z             }t          |          }t	          t
          	          }t          ||||
          \  }|pg D ]}t          |t          j	                  rt          ||||||          }|rx|\  }}}|r.|                    |j        i                               |           |r)|                    di                               |           |r                    |           |pg D ]}t          |t          j	                  rt          ||||||          }|rx|\  }}}|r.|                    |j        i                               |           |r)|                    di                               |           |r                    |           rfdt                    D             |d<   |r||d<   ||d<   |r||d<   |r||d<   t          t!          di |dd          S )N)r2   r   r   rh   termsOfServicer   license)openapiinfor   )ref_template)fieldsr]   r^   r[   r   securitySchemesc                 "    i | ]}||         S r   r   )r   kr   s     rX   r   zget_openapi.<locals>.<dictcomp>
  s     P P PqKN P P PrZ   schemas
componentspathsr   r   TrJ   r   )setr   r   r   r   r   r   rz   r   r   r   r   r   r   sortedr   r   )r2   r   r   r   rh   r   r   r   r   r   r   r   r[   r  outputr  r	  webhook_pathsr   
all_fieldsr^   r]   r_   r   resultr   r   path_definitionswebhookr   s                                @rX   get_openapir    st     &+w??D "!Y *)] 2!1 "!Y '&Y)8$GGF $#y,.J')E/1M!eeM'V\r(:(:T(.b=Q=Q(QRRJ.z::N)|DDD!0)%&C	" " "M; 2 9 9eW-.. 	9%+!1-+.K  F  	9;A8&(8 I$$U%6;;BB4HHH# ))*;R@@GG(   $ 9&&'7888>r 9 9gw/00 	9%+!1-+.K  F  	9;A8&(8 S!,,W-@"EELLTRRR# ))*;R@@GG(   $ 9&&'7888 Q P P P PF;<O<O P P P
9 *)|F7O +*z vG--f--4PPPPrZ   )Lhttp.clientr   r   r   typingr   r   r   r   r   r   r	   r
   r   r   fastapir   fastapi._compatr   r   r   r   r   r   r   r   fastapi.datastructuresr   fastapi.dependencies.modelsr   fastapi.dependencies.utilsr   r   fastapi.encodersr   fastapi.openapi.constantsr   r   r   fastapi.openapi.modelsr   fastapi.paramsr   r    fastapi.responsesr!   fastapi.typesr"   fastapi.utilsr#   r$   r%   starlette.responsesr&   starlette.routingr'   starlette.statusr(   typing_extensionsr)   r   r   rF   r   __annotations__rY   boolrv   r   r   r   r   r   r   r   r  r   rZ   rX   <module>r'     sh          U U U U U U U U U U U U U U U U U U U U U U U U      	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 6 5 5 5 5 5 1 1 1 1 1 1 J J J J J J J J - - - - - - Q Q Q Q Q Q Q Q Q Q * * * * * * & & & & & & & & & & & & & & & & & & & &         
 - , , , , , ' ' ' ' ' ' : : : : : : % % % % % %    2VY4GHI
 

 #H55&99  '&&    #j+<<=
 

( 
( $ !& & DcN   44
4S>4S#X//04 4 4 42 +/& & &z*& )& !	&
 j'"?@@A?R& $(& 
$sCx.& & & &b +/" " "$" )" !	"
 j'"?@@A?R" $(" d38n" " " "JUU(+UU U U U0)9 03 03 0 0 0 0(+<?H	#s(^   F +/}/ }/ }/}/ s8}/ )	}/
 !}/ j'"?@@A?R}/ $(}/ 4S>4S>4S>9:}/ }/ }/ }/@Y	*   F #!!%.2+/:>&*489=*.\Q \Q \Q\Q \Q 	\Q
 c]\Q #\Q Y\Q x	*+\Q 4S#X'
(\Q d4U38_ 4567\Q sm\Q d3c3h/01\Q 4U38_ 456\Q $(\Q 
#s(^\Q \Q \Q \Q \Q \QrZ   