
    dh
                     p    S r SSKJr  SSKJrJr  SSKJr  \" SS9 " S S5      5       rSS	\	S
\
S\4S jjrg)z1Quick and dirty representation for OpenAPI specs.    )	dataclass)ListTuple)dereference_refsT)frozenc                   P    \ rS rSr% Sr\\   \S'   \\S'   \\	\\\4      \S'   Sr
g)ReducedOpenAPISpec	   zA reduced OpenAPI spec.

This is a quick and dirty representation for OpenAPI specs.

Parameters:
    servers: The servers in the spec.
    description: The description of the spec.
    endpoints: The endpoints in the spec.
serversdescription	endpoints N)__name__
__module____qualname____firstlineno____doc__r   dict__annotations__strr   __static_attributes__r       g/var/www/html/shao/venv/lib/python3.13/site-packages/langchain_community/agent_toolkits/openapi/spec.pyr	   r	   	   s/     $ZE#sD.)**r   r	   specdereferencereturnc                    U S   R                  5        VVVVs/ sHM  u  p#UR                  5        H4  u  pEUS;   d  M  UR                  5        SU 3UR                  S5      U4PM6     MO     nnnnnU(       a!  U VVVs/ sH  u  pxnXx[        XPS94PM     nnnnS[        S[        4S jn	U VVVs/ sH  u  pxnXxU	" U5      4PM     nnnn[        U S	   U S
   R                  SS5      US9$ s  snnnnf s  snnnf s  snnnf )a  Simplify/distill/minify a spec somehow.

I want a smaller target for retrieval and (more importantly)
I want smaller results from retrieval.
I was hoping https://openapi.tools/ would have some useful bits
to this end, but doesn't seem so.

Args:
    spec: The OpenAPI spec.
    dereference: Whether to dereference the spec. Default is True.

Returns:
    ReducedOpenAPISpec: The reduced OpenAPI spec.
paths)getpostpatchputdelete r   )full_schemadocsr   c                    0 nU R                  S5      (       a  U R                  S5      US'   U R                  S5      (       a=  U R                  S/ 5       Vs/ sH  nUR                  S5      (       d  M  UPM     snUS'   SU S   ;   a  U S   S   US'   U R                  S5      (       a  U R                  S5      US'   U$ s  snf )Nr   
parametersrequired200	responsesrequestBody)r   )r&   out	parameters      r   reduce_endpoint_docs1reduce_openapi_spec.<locals>.reduce_endpoint_docs:   s    88M""!%-!8C88L!! "&,!;!!;I==, !;!C
 D%%#K07C88M""!%-!8C
!s   C 4C r   info )r   r   r   )itemsupperr   r   r   r	   )
r   r   route	operationoperation_namer&   r   namer   r/   s
             r   reduce_openapi_specr9      s6   $ !%W 3 3 5 5E$-OO$5 NFF 	MN  "#1UG	,dhh}.EtL$5 	M 5    ,5
+4'4  0 HI+4 	 
4 D $ (1'0#Dt 
067'0   YL$$]B7 I
,s    C+
/C+
>C30C:N)T)r   dataclassesr   typingr   r    langchain_core.utils.json_schemar   r	   r   boolr9   r   r   r   <module>r>      sJ    7 !  = $+ + + 8d 8 8AS 8r   