Ë
    üûàgüf  ã                   óz  — d dl Z d dlZd dlZd dlmZ d dlmZmZ d dl	Z	d dl
mZmZ d dlmZ d dlmZ d dlmZ d dlmZmZ d dlmZmZ d d	lmZ d
dlmZ d
dlmZ d
dlm Z  d
dl!m"Z"m#Z#m$Z$ d
dlm%Z%m&Z& d
dl'm(Z(m)Z)m*Z*  ejV                  e,«      Z- ej\                  d«      Z/d„ Z0d„ Z1 G d„ de«      Z G d„ d«      Z2y)é    N)ÚOrderedDictÚdefaultdict)Ú
URLPatternÚURLResolver)Ú
versioning)ÚSchemaGenerator)ÚEndpointEnumerator)Úendpoint_orderingÚget_pk_name)Úget_pk_descriptionÚis_list_view)Úapi_settingsé   )Úopenapi)Úswagger_settings)ÚSwaggerGenerationError)Úget_basic_type_infoÚget_queryset_fieldÚget_queryset_from_view)ÚReferenceResolverÚSwaggerDict)Úforce_real_strÚget_consumesÚget_producesz{(?P<parameter>\w+)}c                 ó  — | D �cg c]"  }|j                  d«      j                  d«      ‘Œ$ }}t        |«      }t        |«      }|}t	        |«      D ]  \  }}|||   k7  sŒ|d | } n ddj                  |«      z   S c c}w )Nú/)ÚstripÚsplitÚminÚmaxÚ	enumerateÚjoin)ÚpathsÚpathÚsplit_pathsÚs1Ús2ÚcommonÚiÚcs           úQ/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/drf_yasg/generators.pyÚcommon_pathr,      s�   € Ø:?Ö@°$�4—:‘:˜c“?×(Ñ(¨Õ-Ð@€KÐ@Ü	ˆ[Ó	€BÜ	ˆ[Ó	€BØ€FÜ˜"“ò ‰ˆˆ1Ø��1‘‹:Ø˜˜�VˆFÙðð �—‘˜&Ó!Ñ!Ð!ùò As   …'A<c                 ó
   — | dvS )N>   ÚlistÚcreateÚupdateÚdestroyÚretrieveÚpartial_update© )Úactions    r+   Úis_custom_actionr6   (   s   € Øð ð ð ó    c                   óP   ‡ — e Zd Zdˆ fd„	Zˆ fd„Zd	ˆ fd„	Zd„ Zd
d„Zd„ Zd„ Z	ˆ xZ
S )r	   c                 ó<   •— t         t        | �  ||«       || _        y ©N)Úsuperr	   Ú__init__Úrequest)ÚselfÚpatternsÚurlconfr=   Ú	__class__s       €r+   r<   zEndpointEnumerator.__init__/   s   ø€ ÜÔ  $Ñ0°¸7ÔCØˆ�r7   c                 ó–   •— |j                  d«      rt        j                  d|«       | j                  t        t
        | �  |«      «      S )Nú)zEurl pattern does not end in $ ('%s') - unexpected things might happen)ÚendswithÚloggerÚwarningÚunescape_pathr;   r	   Úget_path_from_regex)r>   Ú
path_regexrA   s     €r+   rH   z&EndpointEnumerator.get_path_from_regex3   s@   ø€ Ø×Ñ˜sÔ#Ü�N‰NÐbÐdnÔoØ×!Ñ!¤%Ô(:¸DÑ"UÐV`Ó"aÓbÐbr7   c                 ó0  •— t         t        | �  ||«      syt        | j                  dd «      }t        |j
                  dd «      }|�0t        |t        j                  «      r|r||j                  d«      vryt        |j
                  dt        «       «      €yy)NFÚversionÚversioning_classú:Úswagger_schemaT)r;   r	   Úshould_include_endpointÚgetattrr=   ÚclsÚ
issubclassr   ÚNamespaceVersioningr   Úobject)	r>   r$   ÚcallbackÚapp_nameÚ	namespaceÚurl_namerK   rL   rA   s	           €r+   rO   z*EndpointEnumerator.should_include_endpoint8   s†   ø€ ÜÔ'¨ÑFÀtÈXÔVØä˜$Ÿ,™,¨	°4Ó8ˆÜ" 8§<¡<Ð1CÀTÓJÐØÐ'¬JÐ7GÌ×IgÑIgÔ,hÙ˜7¨)¯/©/¸#Ó*>Ñ>Øä�8—<‘<Ð!1´6³8Ó<ÐDØàr7   c                 ó>  — t        |j                  dd«      }|�ƒt        |t        j                  «      rit        | j
                  dd«      }|rPt        |dd«      }d|z  }||vr(t        j                  d|j                  ›d|›d|›�«       |j                  ||«      }|S )	a"  If ``request.version`` is not ``None`` and `callback` uses ``URLPathVersioning``, this function replaces
        the ``version`` parameter in `path` with the actual version.

        :param str path: the templated path
        :param callback: the view callback
        :rtype: str
        rL   NrK   Úversion_paramú{%s}zview z  uses URLPathVersioning but URL z has no param )	rP   rQ   rR   r   ÚURLPathVersioningr=   rE   ÚinfoÚreplace)r>   r$   rU   rL   rK   rZ   s         r+   Úreplace_versionz"EndpointEnumerator.replace_versionG   s—   € ô # 8§<¡<Ð1CÀTÓJÐØÐ'¬JÐ7GÌ×IeÑIeÔ,fÜ˜dŸl™l¨I°tÓ<ˆGÙÜ 'Ð(8¸/È9Ó U�Ø &¨Ñ 6�Ø ¨Ñ,Ü—K’KØ#+§<£<²±}ð!Fô Gà—|‘| M°7Ó;�àˆr7   c           	      óœ  — |€| j                   }g }|€
t        «       }|D �]q  }|t        |j                  «      z   }t	        |t
        «      rœ	 | j                  |«      }	|j                  }
|j                  }| j                  |	|
|xs d|xs d|«      rT| j                  |	|
«      }	|	|v rŒŠ|j                  |	«       | j                  |
«      D ]  }|	||
f}|j                  |«       Œ ŒÈt	        |t"        «      rm| j%                  |j&                  ||r|›d|j(                  ›�n|j(                  |r|›d|j*                  ›�n|j*                  |¬«      }|j-                  |«       �ŒEt        j!                  dj/                  t1        |«      «      «       �Œt t3        |t4        ¬«      }|S # t        $ r t        j!                  dd¬«       Y �Œ«w xY w)	z
        Return a list of all available API endpoints by inspecting the URL conf.

        Copied entirely from super.
        Ú zfailed to enumerate viewT)Úexc_inforM   )r?   ÚprefixrV   rW   Úignored_endpointszunknown pattern type {}©Úkey)r?   ÚsetÚstrÚpatternÚ
isinstancer   rH   rU   ÚnamerO   r_   ÚaddÚget_allowed_methodsÚappendÚ	ExceptionrE   rF   r   Úget_api_endpointsÚurl_patternsrV   rW   ÚextendÚformatÚtypeÚsortedr
   )r>   r?   rc   rV   rW   rd   Úapi_endpointsri   rI   r$   rU   rX   ÚmethodÚendpointÚnested_endpointss                  r+   rp   z$EndpointEnumerator.get_api_endpoints\   sÏ  € ð ÐØ—}‘}ˆHàˆØÐ$Ü #£Ðàó  	PˆGØ¤# g§o¡oÓ"6Ñ6ˆJÜ˜'¤:Ô.ðNØ×3Ñ3°JÓ?�DØ&×/Ñ/�HØ&Ÿ|™|�HØ×3Ñ3°D¸(ÀHÂNÐPRÐT]ÒTcÐacÐemÔnØ#×3Ñ3°D¸(ÓC˜ð  Ð#4Ñ4Ø$Ø)×-Ñ-¨dÔ3à&*×&>Ñ&>¸xÓ&Hò ;˜FØ(,¨f°hÐ'?˜HØ)×0Ñ0°Õ:ð;øô ˜G¤[Ô1Ø#'×#9Ñ#9Ø$×1Ñ1Ø%ÙGOª°'×2BÒ2BÑCÐU\×UeÑUeÙJSª°G×4EÒ4EÑFÐY`×YjÑYjØ&7ð $:ó $Ð ð ×$Ñ$Ð%5Ö6ä—‘Ð8×?Ñ?ÄÀWÃÓNÖOðA 	PôD ˜}Ô2CÔDˆàÐøô# !ò NÜ—N‘NÐ#=È�N×MðNús   ÁAF'Â)=F'Æ' GÇ
Gc                 ó0   — t        j                  dd|«      S )zzUnescape all backslash escapes from `s`.

        :param str s: string with backslash escapes
        :rtype: str
        z\\(.)z\1)ÚreÚsub)r>   Úss     r+   ÚunescapezEndpointEnumerator.unescape�   s   € ô �v‰v�h  qÓ)Ð)r7   c                 ó  — d}|r|t         j                  |«      }|s|| j                  |«      z  }	 |S || j                  |d|j                  «        «      z  }||j	                  «       z  }||j                  «       d }|rŒ||S )aÕ  Remove backslashes escapes from all path components outside {parameters}. This is needed because
        ``simplify_regex`` does not handle this correctly.

        **NOTE:** this might destructively affect some url regex patterns that contain metacharacters (e.g. \w, \d)
        outside path parameter groups; if you are in this category, God help you

        :param str path: path possibly containing
        :return: the unescaped path
        :rtype: str
        ra   N)ÚPATH_PARAMETER_REÚsearchr~   ÚstartÚgroupÚend)r>   r$   Ú
clean_pathÚmatchs       r+   rG   z EndpointEnumerator.unescape_path˜   sŽ   € ð ˆ
ÙÜ%×,Ñ,¨TÓ2ˆEÙØ˜dŸm™m¨DÓ1Ñ1�
Øð
 Ðð	 ˜$Ÿ-™-¨¨^¨e¯k©k«mÐ(<Ó=Ñ=ˆJØ˜%Ÿ+™+›-Ñ'ˆJØ˜Ÿ	™	›˜Ð%ˆDò ð Ðr7   )NNN)ra   ra   N)Nra   NNN)Ú__name__Ú
__module__Ú__qualname__r<   rH   rO   r_   rp   r~   rG   Ú__classcell__)rA   s   @r+   r	   r	   .   s(   ø„ õôcõ
òó*1òf*ör7   r	   c                   óž   — e Zd ZdZeZeZddddddœZdd	„Z	e
d
„ «       Zd„ Zd„ Zdd„Zdd„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚOpenAPISchemaGeneratorzÛ
    This class iterates over all registered API endpoints and returns an appropriate OpenAPI 2.0 compliant schema.
    Method implementations shamelessly stolen and adapted from rest-framework ``SchemaGenerator``.
    r2   r/   r0   r3   r1   )ÚgetÚpostÚputÚpatchÚdeleteNc                 óì  — t        |j                  ||j                  dd«      ||«      | _        || _        || _        g | _        g | _        t        j                  | _
        |€ t        j                  �t        j                  }|rqt        j                  |«      }|j                  dvs|j                  st!        d«      ‚|j"                  rt$        j'                  d|z  «       y|| j                  _        yy)a  

        :param openapi.Info info: information about the API
        :param str version: API version string; if omitted, `info.default_version` will be used
        :param str url: API scheme, host and port; if ``None`` is passed and ``DEFAULT_API_URL`` is not set, the url
            will be inferred from the request made against the schema view, so you should generally not need to set
            this parameter explicitly; if the empty string is passed, no host and scheme will be emitted

            If `url` is not ``None`` or the empty string, it must be a scheme-absolute uri (i.e. starting with http://
            or https://), and any path component is ignored;

            See also: :ref:`documentation on base URL construction <custom-spec-base-url>`
        :param patterns: if given, only these patterns will be enumerated for inclusion in the API spec
        :param urlconf: if patterns is not given, use this urlconf to enumerate patterns;
            if not given, the default urlconf is used
        Údescriptionra   N)ÚhttpÚhttpsz%`url` must be an absolute HTTP(S) urlzKpath component of api base URL %s is ignored; use FORCE_SCRIPT_NAME instead)r   Útitler�   Ú_genr]   rK   ÚconsumesÚproducesr   ÚSCHEMA_COERCE_METHOD_NAMESÚcoerce_method_namesr   ÚDEFAULT_API_URLÚurlparseÚschemeÚnetlocr   r$   rE   rF   Úurl)r>   r]   rK   r    r?   r@   Ú
parsed_urls          r+   r<   zOpenAPISchemaGenerator.__init__Á   sÏ   € ô" $ D§J¡J°°T·X±X¸mÈRÓ5PÐRZÐ\cÓdˆŒ	ØˆŒ	ØˆŒØˆŒØˆŒÜ#/×#JÑ#JˆÔ àˆ;Ô+×;Ñ;ÐGÜ"×2Ñ2ˆCáÜ!×*Ñ*¨3Ó/ˆJØ× Ñ Ð(9Ñ9À×ARÒARÜ,Ð-TÓUÐUØ�ŠÜ—‘ÐlÐorÑrÕsà #�—	‘	•ð r7   c                 ó.   — | j                   j                  S r:   )r—   r    )r>   s    r+   r    zOpenAPISchemaGenerator.urlå   s   € à�y‰y�}‰}Ðr7   c                 óV   — t         j                  }|�t        j                  |i «      }|S )a  Get the security schemes for this API. This determines what is usable in security requirements,
        and helps clients configure their authorization credentials.

        :return: the security schemes usable with this API
        :rtype: dict[str,dict] or None
        )r   ÚSECURITY_DEFINITIONSr   Ú	_as_odict)r>   Úsecurity_definitionss     r+   Úget_security_definitionsz/OpenAPISchemaGenerator.get_security_definitionsé   s0   € ô  0×DÑDÐØÐ+Ü#.×#8Ñ#8Ð9MÈrÓ#RÐ à#Ð#r7   c                 óÈ   — t         j                  }|€|D �cg c]  }|g i‘Œ }}|D �cg c]  }t        j                  |i «      ‘Œ }}t	        |t
        ¬«      }|S c c}w c c}w )aj  Get the base (global) security requirements of the API. This is never called if
        :meth:`.get_security_definitions` returns `None`.

        :param security_definitions: security definitions as returned by :meth:`.get_security_definitions`
        :return: the security schemes accepted by default
        :rtype: list[dict[str,list[str]]] or None
        re   )r   ÚSECURITY_REQUIREMENTSr   r¥   ru   r.   )r>   r¦   Úsecurity_requirementsÚsecurity_schemeÚsrs        r+   Úget_security_requirementsz0OpenAPISchemaGenerator.get_security_requirementsö   sm   € ô !1× FÑ FÐØ Ð(ØRfÖ$g¸ o°rÒ%:Ð$gÐ!Ð$gàI^Ö _À2¤×!6Ñ!6°r¸2Õ!>Ð _ÐÐ _Ü &Ð'<Ä$Ô GÐØ$Ð$ùò	 %hùâ _s
   —A¨Ac                 óH  — | j                  |«      }| j                  t        j                  d¬«      }t	        t
        j                  «      | _        t        t
        j                  «      | _
        | j                  ||||«      \  }}| j                  «       }|r| j                  |«      }nd}| j                  }	|	€|�|j                  «       }	t        j                   d| j"                  || j                  xs d| j                  xs d|||	|| j$                  dœ	t'        |«      ¤ŽS )aª  Generate a :class:`.Swagger` object representing the API schema.

        :param request: the request used for filtering accessible endpoints and finding the spec URI
        :type request: rest_framework.request.Request or None
        :param bool public: if True, all endpoints are included regardless of access through `request`

        :return: the generated Swagger specification
        :rtype: openapi.Swagger
        T)Ú
force_initN)	r]   r#   r˜   r™   r¦   ÚsecurityÚ_urlÚ_prefixÚ_versionr4   )Úget_endpointsÚreference_resolver_classr   ÚSCHEMA_DEFINITIONSr   r   ÚDEFAULT_PARSER_CLASSESr˜   r   ÚDEFAULT_RENDERER_CLASSESr™   Ú	get_pathsr§   r­   r    Úbuild_absolute_uriÚSwaggerr]   rK   Údict)
r>   r=   ÚpublicÚ	endpointsÚ
componentsr#   rc   r¦   rª   r    s
             r+   Ú
get_schemaz!OpenAPISchemaGenerator.get_schema  s  € ð ×&Ñ& wÓ/ˆ	Ø×2Ñ2´7×3MÑ3MÐZ^Ð2Ó_ˆ
Ü$¤\×%HÑ%HÓIˆŒÜ$¤\×%JÑ%JÓKˆŒØŸ™ y°*¸gÀvÓN‰ˆˆvà#×<Ñ<Ó>ÐÙØ$(×$BÑ$BÐCWÓ$XÑ!à$(Ð!à�h‰hˆØˆ;˜7Ð.Ø×,Ñ,Ó.ˆCä�‰ð 
Ø—‘ %°$·-±-Ò2GÀ4ÐRV×R_ÑR_ÒRgÐcgØ!5Ð@UØ˜f¨t¯|©|ñ
ô @DÀJÓ?Oñ
ð 	
r7   c                 óö   — | j                   j                  |||«      }t        |dd«      }|�?|j                  «       D ],  \  }}t        ||d«      }|€Œt	        |j
                  d|«       Œ. t	        |dd«       |S )aP  Create a view instance from a view callback as registered in urlpatterns.

        :param callback: view callback registered in urlpatterns
        :param str method: HTTP method
        :param request: request to bind to the view
        :type request: rest_framework.request.Request or None
        :return: the view instance
        Ú_swagger_auto_schemaNÚswagger_fake_viewT)r—   Úcreate_viewrP   ÚitemsÚsetattrÚ__func__)r>   rU   rw   r=   ÚviewÚ	overridesÚ_Úview_methods           r+   rÄ   z"OpenAPISchemaGenerator.create_view&  sˆ   € ð �y‰y×$Ñ$ X¨v°wÓ?ˆÜ˜HÐ&<¸dÓCˆ	ØÐ à&Ÿ_™_Ó.ò U‘	�˜Ü% d¨F°DÓ9�ØÑ*Ü˜K×0Ñ0Ð2HÈ)ÕTðUô
 	�Ð)¨4Ô0Øˆr7   c                 ó„   — d|vr|S t        t        |«      dd«      }|rt        |«      }nd}|j                  dd|z  «      S )aK  Coerce {pk} path arguments into the name of the model field, where possible. This is cleaner for an
        external representation (i.e. "this is an identifier", not "this is a database primary key").

        :param str path: the path
        :param rest_framework.views.APIView view: associated view
        :rtype: str
        z{pk}ÚmodelNÚidr[   )rP   r   r   r^   )r>   r$   rÈ   rÍ   Ú
field_names        r+   Úcoerce_pathz"OpenAPISchemaGenerator.coerce_path;  sM   € ð ˜ÑØˆKäÔ.¨tÓ4°g¸tÓDˆÙÜ$ UÓ+‰JàˆJØ�|‰|˜F F¨ZÑ$7Ó8Ð8r7   c                 óÄ  — | j                  | j                  j                  | j                  j                  |¬«      }|j	                  «       }t        t        «      }i }|D ]P  \  }}}| j                  |||«      }	| j                  ||	«      }||   j                  ||	f«       |j                  ||<   ŒR |j                  «       D ��
ci c]  \  }}
|||   |
f“Œ c}
}S c c}
}w )a  Iterate over all the registered endpoints in the API and return a fake view with the right parameters.

        :param request: request to bind to the endpoint views
        :type request: rest_framework.request.Request or None
        :return: {path: (view_class, list[(http_method, view_instance)])
        :rtype: dict[str,(type,list[(str,rest_framework.views.APIView)])]
        )r=   )Úendpoint_enumerator_classr—   r?   r@   rp   r   r.   rÄ   rÐ   rn   rQ   rÅ   )r>   r=   Ú
enumeratorr¾   Ú
view_pathsÚview_clsr$   rw   rU   rÈ   Úmethodss              r+   r´   z$OpenAPISchemaGenerator.get_endpointsM  sà   € ð ×3Ñ3°D·I±I×4FÑ4FÈÏ	É	×HYÑHYÐcjÐ3Ókˆ
Ø×0Ñ0Ó2ˆ	ä ¤Ó&ˆ
ØˆØ&/ò 	*Ñ"ˆD�&˜(Ø×#Ñ# H¨f°gÓ>ˆDØ×#Ñ# D¨$Ó/ˆDØ�tÑ×#Ñ# V¨T NÔ3Ø%Ÿ\™\ˆH�TŠNð		*ð
 FP×EUÑEUÓEW×X±M°D¸'��x ‘~ wÐ/Ñ/ÓXÐXùÓXs   ÃCc                 óL  — t        |d«      r|j                  }n-t        |||«      rd}n| j                  |j	                  «          }|j                  d«      j                  d«      D �cg c]  }d|vr|‘Œ
 }}t        |«      rv|j                  D �ch c]
  }|dk7  sŒ	|’Œ }}t        |«      dkD  r@| j                  j	                  «          }|| j                  v r| j                  |   }||gz   S |dd |gz   S || j                  v r| j                  |   }||gz   S c c}w c c}w )	aX  Return a list of keys that should be used to group an operation within the specification. ::

          /users/                   ("users", "list"), ("users", "create")
          /users/{pk}/              ("users", "read"), ("users", "update"), ("users", "delete")
          /users/enabled/           ("users", "enabled")  # custom viewset list action
          /users/{pk}/star/         ("users", "star")     # custom viewset detail action
          /users/{pk}/groups/       ("users", "groups", "list"), ("users", "groups", "create")
          /users/{pk}/groups/{pk}/  ("users", "groups", "read"), ("users", "groups", "update")

        :param str subpath: path to the operation with any common prefix/base path removed
        :param str method: HTTP method
        :param view: the view associated with the operation
        :rtype: list[str]
        r5   r.   r   ú{Úheadr   Néÿÿÿÿ)Úhasattrr5   r   Údefault_mappingÚlowerr   r   r6   Ú
action_mapÚlenr›   )r>   Úsubpathrw   rÈ   r5   Ú	componentÚnamed_path_componentsÚmapped_methodss           r+   Úget_operation_keysz)OpenAPISchemaGenerator.get_operation_keysa  sH  € ô �4˜Ô"à—[‘[‰Fô ˜G V¨TÔ2Ø‘à×-Ñ-¨f¯l©l«nÑ=�ð �}‰}˜SÓ!×'Ñ'¨Ó,ö!
Ø#à˜)Ñ#ò ð!
Ðð !
ô ˜FÔ#ð &*§_¡_öà!¸À&Ó8H’ðˆNð ô �>Ó" QÒ&Ø×-Ñ-¨f¯l©l«nÑ=�Ø˜T×5Ñ5Ñ5Ø!×5Ñ5°fÑ=�FØ,°¨xÑ7Ð7à,¨S¨bÐ1°V°HÑ<Ð<à�T×-Ñ-Ñ-Ø×-Ñ-¨fÑ5ˆFð %¨ xÑ/Ð/ùò1!
ùòs   Á)DÂ
D!ÂD!c                 ó  — g }|D ]q  }|j                  d«      j                  d«      }g }|D ]  }d|v r n|j                  |«       Œ dj                  |dd «      }|s y|j                  d|z   dz   «       Œs t	        |«      S )aë  
        Given a list of all paths, return the common prefix which should be
        discounted when generating a schema structure.

        This will be the longest common string that does not include that last
        component of the URL, or the last component before a path parameter.

        For example: ::

            /api/v1/users/
            /api/v1/users/{pk}/

        The path prefix is ``/api/v1/``.

        :param list[str] paths: list of paths
        :rtype: str
        r   rØ   NrÚ   )r   r   rn   r"   r,   )r>   r#   Úprefixesr$   r¿   Úinitial_componentsrá   rc   s           r+   Údetermine_path_prefixz,OpenAPISchemaGenerator.determine_path_prefix”  s    € ð$ ˆØò 	0ˆDØŸ™ C›×.Ñ.¨sÓ3ˆJØ!#ÐØ'ò 5�	Ø˜)Ñ#ÙØ"×)Ñ)¨)Õ4ð5ð —X‘XÐ0°°"Ð5Ó6ˆFÙñ Ø�O‰O˜C &™L¨3Ñ.Õ/ð	0ô ˜8Ó$Ð$r7   c                 óD   — |xs | j                   j                  |||«      S )a†  Check if a given endpoint should be included in the resulting schema.

        :param str path: request path
        :param str method: http request method
        :param view: instantiated view callback
        :param bool public: if True, all endpoints are included regardless of access through `request`
        :returns: true if the view should be excluded
        :rtype: bool
        )r—   Úhas_view_permissions)r>   r$   rw   rÈ   r½   s        r+   rO   z.OpenAPISchemaGenerator.should_include_endpoint¶  s"   € ð ÒK˜Ÿ™×7Ñ7¸¸fÀdÓKÐKr7   c                 ó.   — t        j                  |¬«      S )zßConstruct the Swagger Paths object.

        :param OrderedDict[str,openapi.PathItem] paths: mapping of paths to :class:`.PathItem` objects
        :returns: the :class:`.Paths` object
        :rtype: openapi.Paths
        ©r#   )r   ÚPaths)r>   r#   s     r+   Úget_paths_objectz'OpenAPISchemaGenerator.get_paths_objectÂ  s   € ô �}‰} 5Ô)Ð)r7   c           
      ó:  — |st        j                  i ¬«      dfS | j                  t        |j	                  «       «      «      xs d}d|vsJ d«       ‚t        «       }t        |j                  «       «      D ]’  \  }\  }}	i }
|	D ]F  \  }}| j                  ||||«      sŒ| j                  ||||||«      }|€Œ4||
|j                  «       <   ŒH |
sŒY|t        |«      d }|j                  d«      sd|z   }| j                  |||
«      ||<   Œ” | j                  |«      |fS )a+  Generate the Swagger Paths for the API from the given endpoints.

        :param dict endpoints: endpoints as returned by get_endpoints
        :param ReferenceResolver components: resolver/container for Swagger References
        :param Request request: the request made against the schema view; can be None
        :param bool public: if True, all endpoints are included regardless of access through `request`
        :returns: the :class:`.Paths` object and the longest common path prefix, as a 2-tuple
        :rtype: tuple[openapi.Paths,str]
        rì   ra   rØ   z,base path cannot be templated in swagger 2.0Nr   )r   rí   rè   r.   Úkeysr   ru   rÅ   rO   Úget_operationrÝ   rß   Ú
startswithÚget_path_itemrî   )r>   r¾   r¿   r=   r½   rc   r#   r$   rÕ   rÖ   Ú
operationsrw   rÈ   Ú	operationÚpath_suffixs                  r+   r¹   z OpenAPISchemaGenerator.get_pathsË  s>  € ñ Ü—=‘= rÔ*¨BÐ.Ð.à×+Ñ+¬D°·±Ó1AÓ,BÓCÒIÀrˆØ˜&Ñ ÐPÐ"PÓPÐ ä“ˆÜ)/°	·±Ó0AÓ)Bò 	TÑ%ˆDÑ%�8˜WØˆJØ 'ò ;‘�˜Ø×3Ñ3°D¸&À$ÈÔOØà ×.Ñ.¨t°T¸6À6È:ÐW^Ó_�	ØÑ(Ø1:�J˜vŸ|™|›~Ò.ð;ò ð #¤3 v£; <Ð0�Ø"×-Ñ-¨cÔ2Ø"%¨Ñ"3�KØ%)×%7Ñ%7¸¸hÈ
Ó%S��kÒ"ð!	Tð$ ×$Ñ$ UÓ+¨VÐ3Ð3r7   c           	      óÔ  — | j                  |t        |«      d ||«      }| j                  ||«      }t        j                  }	t        |d|	«      }	|j                  d|	«      }	|	€y |	|||||||«      }
|
j                  |«      }|€yd|v r-t        |j                  «      t        | j                  «      k(  r|`	d|v r-t        |j                  «      t        | j                  «      k(  r|`
|S )a÷  Get an :class:`.Operation` for the given API endpoint (path, method). This method delegates to
        :meth:`~.inspectors.ViewInspector.get_operation` of a :class:`~.inspectors.ViewInspector` determined
        according to settings and :func:`@swagger_auto_schema <.swagger_auto_schema>` overrides.

        :param view: the view associated with this endpoint
        :param str path: the path component of the operation URL
        :param str prefix: common path prefix among all endpoints
        :param str method: the http method of the operation
        :param openapi.ReferenceResolver components: referenceable components
        :param Request request: the request made against the schema view; can be None
        :rtype: openapi.Operation
        NrN   Úauto_schemar˜   r™   )rä   rß   Úget_overridesr   ÚDEFAULT_AUTO_SCHEMA_CLASSrP   r�   rñ   rg   r˜   r™   )r>   rÈ   r$   rc   rw   r¿   r=   Úoperation_keysrÉ   Úview_inspector_clsÚview_inspectorrõ   s               r+   rñ   z$OpenAPISchemaGenerator.get_operationð  sø   € ð ×0Ñ0°´c¸&³k°lÐ1CÀVÈTÓRˆØ×&Ñ& t¨VÓ4ˆ	ô .×GÑGÐä$ TÐ+;Ð=OÓPÐà&Ÿ]™]¨=Ð:LÓMÐàÐ%Øá+¨D°$¸À
ÈGÐU^Ð`nÓoˆØ"×0Ñ0°Ó@ˆ	ØÐØà˜Ñ"¤s¨9×+=Ñ+=Ó'>Ä#ÀdÇmÁmÓBTÒ'TØÐ"Ø˜Ñ"¤s¨9×+=Ñ+=Ó'>Ä#ÀdÇmÁmÓBTÒ'TØÐ"ØÐr7   c                 óT   — | j                  ||«      }t        j                  dd|i|¤ŽS )a�  Get a :class:`.PathItem` object that describes the parameters and operations related to a single path in the
        API.

        :param str path: the path
        :param type view_cls: the view that was bound to this path in urlpatterns
        :param dict[str,openapi.Operation] operations: operations defined on this path, keyed by lowercase HTTP method
        :rtype: openapi.PathItem
        Ú
parametersr4   )Úget_path_parametersr   ÚPathItem)r>   r$   rÕ   rô   Úpath_parameterss        r+   ró   z$OpenAPISchemaGenerator.get_path_item  s/   € ð ×2Ñ2°4¸ÓBˆÜ×ÑÑI¨?ÐI¸jÑIÐIr7   c                 ó¬   — |j                  «       }t        |d|«      }t        ||d«      }t        |di «      }||v r||   }t        j                  |«      S )a"  Get overrides specified for a given operation.

        :param view: the view associated with the operation
        :param str method: HTTP method
        :return: a dictionary containing any overrides set by :func:`@swagger_auto_schema <.swagger_auto_schema>`
        :rtype: dict
        r5   NrÂ   )rÝ   rP   ÚcopyÚdeepcopy)r>   rÈ   rw   r5   Úaction_methodrÉ   s         r+   rù   z$OpenAPISchemaGenerator.get_overrides"  s[   € ð —‘“ˆÜ˜˜x¨Ó0ˆÜ  f¨dÓ3ˆÜ˜MÐ+AÀ2ÓFˆ	Ø�YÑØ! &Ñ)ˆIä�}‰}˜YÓ'Ð'r7   c           	      ó4  — g }t        |«      }t        j                  |«      D ]ò  }t        ||«      \  }}t	        |«      xs dt
        j                  i}t        |dd«      |k(  r6|d   t
        j                  k(  r t        |d|j                  dd«      «      |d<   |rt        |dd«      r|j                  }	n|rt        |dd«      rt        ||«      }	nd}	t        j                  d|t        |	«      d	t
        j                  d
œ|¤Ž}
|j                  |
«       Œô |S )a  Return a list of Parameter instances corresponding to any templated path variables.

        :param str path: templated request path
        :param type view_cls: the view class associated with the path
        :return: path parameters
        :rtype: list[openapi.Parameter]
        rt   Úlookup_fieldNÚlookup_value_regexri   Ú	help_textFÚprimary_keyT)rk   r“   ÚrequiredÚin_r4   )r   ÚuritemplateÚ	variablesr   r   r   ÚTYPE_STRINGrP   r�   r
  r   Ú	Parameterr   ÚIN_PATHrn   )r>   r$   rÕ   rÿ   ÚquerysetÚvariablerÍ   Úmodel_fieldÚattrsr“   Úfields              r+   r   z*OpenAPISchemaGenerator.get_path_parameters3  s   € ð ˆ
Ü)¨(Ó3ˆä#×-Ñ-¨dÓ3ò 	%ˆHÜ!3°H¸hÓ!GÑˆE�;Ü'¨Ó4ÒU¸Ä×ATÑATÐ8UˆEÜ�x °Ó6¸(ÒBÀuÈVÁ}ÔX_×XkÑXkÒGkÜ#*¨8Ð5IÈ5Ï9É9ÐU^Ð`dÓKeÓ#f��iÑ áœw {°KÀÔGØ)×3Ñ3‘Ù¤¨°mÀUÔ!KÜ0°¸ÓD‘à"�ä×%Ñ%ð ØÜ*¨;Ó7ØÜ—O‘Oñ	ð
 ñˆEð ×Ñ˜eÕ$ð)	%ð, Ðr7   )ra   NNN)NFr:   )r‡   rˆ   r‰   Ú__doc__r	   rÒ   r   rµ   rÜ   r<   Úpropertyr    r§   r­   rÀ   rÄ   rÐ   r´   rä   rè   rO   rî   r¹   rñ   ró   rù   r   r4   r7   r+   rŒ   rŒ   °   sš   „ ñð !3ÐØ0Ðð ØØØ!Øñ€Oó"$ðH ñó ðò$ò%ó 
ó@ò*9ò$Yò(10òf %òD
Lò*ò#4òJ$òL
Jò(ó"!r7   rŒ   )3r  Úloggingr{   Úurllib.parseÚparser�   Úcollectionsr   r   r  Údjango.urlsr   r   Úrest_frameworkr   Úrest_framework.schemas.openapir   Ú!rest_framework.schemas.generatorsr	   Ú_EndpointEnumeratorr
   r   Úrest_framework.schemas.utilsr   r   Úrest_framework.settingsr   ra   r   Úapp_settingsr   Úerrorsr   Úinspectors.fieldr   r   r   r   r   Úutilsr   r   r   Ú	getLoggerr‡   rE   Úcompiler€   r,   r6   rŒ   r4   r7   r+   ú<module>r+     sŽ   ðÛ Û Û 	Ý ß 0ã ß /Ý %Ý :Ý Wß Lß IÝ 0å Ý *Ý *ß ]Ñ ]ß 3ß =Ñ =à	ˆ×	Ñ	˜8Ó	$€à�B—J‘JÐ6Ó7Ð ò	"òôÐ,ô ÷Ddò dr7   