a
    ΝGdZy                     @   s<  d dl Z d dlZd dl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 ddlmZmZmZ zd dl mZ W n ey   e ZY n0 eeZd	Zd
ZdZdZdZdZdZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-d Z.d!Z/d"Z0d#Z1d$Z2d%Z3d&d' Z4d(d) Z5G d*d+ d+eZ6G d,d- d-e6Z7G d.d/ d/e6Z8G d0d1 d1e6Z9G d2d3 d3e6Z:G d4d5 d5e6Z;G d6d7 d7e6Z<G d8d9 d9e6Z=d:d; Z>G d<d= d=e6Z?G d>d? d?e6Z@G d@dA dAe6ZAG dBdC dCe6ZBG dDdE dEeBZCeAeCfeA_DdFdG ZEG dHdI dIe6ZFG dJdK dKe6ZGG dLdM dMeHZIdS )N    N)OrderedDict)get_script_prefix)Promise)camelize   )dict_has_ordered_keysfilter_noneforce_real_str)abcobjectstringnumberintegerbooleanarrayfiledatez	date-timepasswordbinarybytesfloatdoubleZint32Zint64emailZipv4Zipv6uriuuidZslugdecimalbodypathqueryZformDataheaderdefinitionsc                 C   s@   | dkrdS |  dr.dt| dd dd S t| d	ddS )
an  
    Convert a python variable name into a Swagger spec attribute name.

    In particular,
     * if name starts with ``x_``, return ``x-{camelCase}``
     * if name is ``ref``, return ``$ref``
     * else return the name converted to camelCase, with trailing underscores stripped

    :param str attribute_name: python attribute name
    :return: swagger name
    ref$refZx_zx-   NF)Zuppercase_first_letter_)
startswithr   rstrip)Zattribute_name r'   L/var/www/html/django/DPS/env/lib/python3.9/site-packages/drf_yasg/openapi.pymake_swagger_name;   s
    
r)   c                 C   s&   t | tsJ | | }t| |S N)
issubclassSwaggerDict__new__r   __init__)clsresultr'   r'   r(   _bare_SwaggerDictN   s    

r1   c                       sd   e Zd ZdZ fddZ fddZdd Z fdd	Zd
d Ze	dd Z
dd Zdd Z  ZS )r,   a0  A particular type of OrderedDict, which maps all attribute accesses to dict lookups using
     :func:`.make_swagger_name`. Attribute names starting with ``_`` are set on the object as-is and are not included
     in the specification output.

     Used as a base class for all Swagger helper models.
    c                    s,   t t|   || _t| tkr(|   d S r*   )superr,   r.   	_extras__type_insert_extras__selfattrs	__class__r'   r(   r.   ]   s    zSwaggerDict.__init__c                    s8   | dr tt| || d S |d ur4|| t|< d S Nr$   )r%   r2   r,   __setattr__r)   r7   keyvaluer9   r'   r(   r<   c   s
    
zSwaggerDict.__setattr__c                 C   sN   | drtz| t| W S  tyH   tdt| j d | Y n0 d S )Nr$   zobject of class z has no attribute )r%   AttributeErrorr)   KeyErrorr4   __name__r7   itemr'   r'   r(   __getattr__j   s    
zSwaggerDict.__getattr__c                    s,   | drtt| | d S | t|= d S r;   )r%   r2   r,   __delattr__r)   rC   r9   r'   r(   rF   s   s    
zSwaggerDict.__delattr__c                 C   s(   t | j D ]\}}t| || qdS )a@  
        From an ordering perspective, it is desired that extra attributes such as vendor extensions stay at the
        bottom of the object. However, python2.7's OrderedDict craps out if you try to insert into it before calling
        init. This means that subclasses must call super().__init__ as the first statement of their own __init__,
        which would result in the extra attributes being added first. For this reason, we defer the insertion of the
        attributes and require that subclasses call ._insert_extras__ at the end of their __init__ method.
        N)sortedr3   itemssetattr)r7   attrvalr'   r'   r(   r5   y   s    zSwaggerDict._insert_extras__c                    s   t |  v r t |  S t| tr4t| dr4|  } t| tjrt }| t | < |  }t	| sjt
|}|D ]\}}t| ||< qn|S t| trt| S t| tjrt| tjst|  fdd| D S | S )z*Implementation detail of :meth:`.as_odict`_proxy____castc                 3   s   | ]}t | V  qd S r*   r,   	_as_odict).0elemmemor'   r(   	<genexpr>       z(SwaggerDict._as_odict.<locals>.<genexpr>)id
isinstancer   hasattrrL   collections_abcMappingr   rH   r   rG   r,   rN   strr	   IterableIteratorr4   )objrR   r0   rH   rJ   rK   r'   rQ   r(   rN      s$    
zSwaggerDict._as_odictc                 C   s   t | i S )z[Convert this object into an ``OrderedDict`` instance.

        :rtype: OrderedDict
        rM   r7   r'   r'   r(   as_odict   s    zSwaggerDict.as_odictc                 C   s2   dd t |  D }tt| f|d t|  fS )Nc                 S   s    i | ]\}}| d s||qS )Z_NP_)r%   rO   kvr'   r'   r(   
<dictcomp>   rT   z*SwaggerDict.__reduce__.<locals>.<dictcomp>)varsrH   r1   r4   iterr6   r'   r'   r(   
__reduce__   s    zSwaggerDict.__reduce__)rB   
__module____qualname____doc__r.   r<   rE   rF   r5   staticmethodrN   r_   rf   __classcell__r'   r'   r9   r(   r,   U   s   	
r,   c                       s   e Zd Zd fdd	Z  ZS )ContactNc                    sT   t t| jf i | |du r6|du r6|du r6td|| _|| _|| _|   dS )zSwagger Contact object

        At least one of the following fields is required:

        :param str name: contact name
        :param str url: contact url
        :param str email: contact e-mail
        Nz@one of name, url or email is requires for Swagger Contact object)r2   rl   r.   AssertionErrornameurlr   r5   )r7   rn   ro   r   extrar9   r'   r(   r.      s    	zContact.__init__)NNNrB   rg   rh   r.   rk   r'   r'   r9   r(   rl      s   rl   c                       s   e Zd Zd fdd	Z  ZS )LicenseNc                    s>   t t| jf i | |du r&td|| _|| _|   dS )zSwagger License object

        :param str name: Required. License name
        :param str url: link to detailed license information
        Nz+name is required for Swagger License object)r2   rr   r.   rm   rn   ro   r5   )r7   rn   ro   rp   r9   r'   r(   r.      s    zLicense.__init__)Nrq   r'   r'   r9   r(   rr      s   rr   c                       s   e Zd Zd fdd	Z  ZS )InfoNc                    s   t t| jf i | |du s&|du r.td|durHt|tsHtd|durbt|tsbtd|| _|| _|| _	|| _
|| _|| _|   dS )a  Swagger Info object

        :param str title: Required. API title.
        :param str default_version: Required. API version string (not to be confused with Swagger spec version)
        :param str description: API description; markdown supported
        :param str terms_of_service: API terms of service; should be a URL
        :param Contact contact: contact object
        :param License license: license object
        Nz6title and version are required for Swagger info objectz contact must be a Contact objectz license must be a License object)r2   rs   r.   rm   rV   rl   rr   title_default_versiondescriptionterms_of_servicecontactlicenser5   )r7   rt   Zdefault_versionrv   rw   rx   ry   rp   r9   r'   r(   r.      s    zInfo.__init__)NNNNrq   r'   r'   r9   r(   rs      s   rs   c                
       s*   e Zd Zd fdd	Zedd Z  ZS )SwaggerNc                    s   t t| jf i | d| _|| _|p*|j| j_|rdt|}|jrJ|j	sRJ d|j| _
|j	g| _| t || _|| _|| _t|| _t|| _|	| _t|
| _|   dS )aM  Root Swagger object.

        :param .Info info: info object
        :param str _url: URL used for setting the API host and scheme
        :param str _prefix: api path prefix to use in setting basePath; this will be appended to the wsgi
            SCRIPT_NAME prefix or Django's FORCE_SCRIPT_NAME if applicable
        :param str _version: version string to override Info
        :param dict[str,dict] security_definitions: list of supported authentication mechanisms
        :param list[dict[str,list[str]]] security: authentication mechanisms accepted globally
        :param list[str] consumes: consumed MIME types; can be overridden in Operation
        :param list[str] produces: produced MIME types; can be overridden in Operation
        :param Paths paths: paths object
        :param dict[str,Schema] definitions: named models
        z2.0z.if given, url must have both schema and netlocN)r2   rz   r.   Zswaggerinforu   versionurlparsenetlocschemehostschemesget_base_pathr   	base_pathconsumesproducesr   security_definitionssecuritypathsr    r5   )r7   r{   _url_prefix_versionr   r   r   r   r   r    rp   ro   r9   r'   r(   r.      s"    




zSwagger.__init__c                 C   sd   |r| dr|dd }|ds,d| }|| }|rN| drN|dd }|ds`d| }|S )a  Determine an appropriate value for ``basePath`` based on the SCRIPT_NAME and the api common prefix.

        :param str script_prefix: script prefix as defined by django ``get_script_prefix``
        :param str api_prefix: api common prefix
        :return: joined base path
        /N)endswithr%   )r/   Zscript_prefixZ
api_prefixr   r'   r'   r(   r     s    	

zSwagger.get_base_path)
NNNNNNNNNN)rB   rg   rh   r.   classmethodr   rk   r'   r'   r9   r(   rz      s
     $rz   c                       s   e Zd Z fddZ  ZS )Pathsc                    sR   t t| jf i | | D ]&\}}|ds4J |dur|| |< q|   dS )zYA listing of all the paths in the API.

        :param dict[str,PathItem] paths:
        r   N)r2   r   r.   rH   r%   r5   )r7   r   rp   r   Zpath_objr9   r'   r(   r.   )  s    
zPaths.__init__rq   r'   r'   r9   r(   r   (  s   r   c                       s2   e Zd Zg dZd fdd	Zedd Z  ZS )PathItem)getputpostdeleteoptionsheadpatchNc	           
         sV   t t| jf i |	 || _|| _|| _|| _|| _|| _|| _	t
|| _|   dS )a  Information about a single path

        :param Operation get: operation for GET
        :param Operation put: operation for PUT
        :param Operation post: operation for POST
        :param Operation delete: operation for DELETE
        :param Operation options: operation for OPTIONS
        :param Operation head: operation for HEAD
        :param Operation patch: operation for PATCH
        :param list[Parameter] parameters: parameters that apply to all operations
        N)r2   r   r.   r   r   r   r   r   r   r   r   
parametersr5   )
r7   r   r   r   r   r   r   r   r   rp   r9   r'   r(   r.   9  s    
zPathItem.__init__c                 C   s   dd |   D S )zA list of all standard Operations on this PathItem object. See :attr:`.OPERATION_NAMES`.

        :return: list of (method name, Operation) tuples
        :rtype: list[tuple[str,Operation]]
        c                 S   s&   g | ]\}}|t jv r|r||fqS r'   )r   OPERATION_NAMESr`   r'   r'   r(   
<listcomp>X  rT   z'PathItem.operations.<locals>.<listcomp>)rH   r^   r'   r'   r(   
operationsQ  s    zPathItem.operations)NNNNNNNN)rB   rg   rh   r   r.   propertyr   rk   r'   r'   r9   r(   r   6  s     r   c                       s   e Zd Zd fdd	Z  ZS )	OperationNc
                    sl   t t| jf i |
 || _|| _|| _t|| _|| _t|| _	t|| _
t|| _t|	| _|   dS )a  Information about an API operation (path + http method combination)

        :param str operation_id: operation ID, should be unique across all operations
        :param Responses responses: responses returned
        :param list[Parameter] parameters: parameters accepted
        :param list[str] consumes: content types accepted
        :param list[str] produces: content types produced
        :param str summary: operation summary; should be < 120 characters
        :param str description: operation description; can be of any length and supports markdown
        :param list[str] tags: operation tags
        :param list[dict[str,list[str]]] security: list of security requirements
        N)r2   r   r.   operation_idsummaryrv   r   r   	responsesr   r   tagsr   r5   )r7   r   r   r   r   r   r   rv   r   r   rp   r9   r'   r(   r.   \  s    




zOperation.__init__)NNNNNNNrq   r'   r'   r9   r(   r   [  s     r   c                 C   sf   |r| t krtd| t kr(|s(td|r<| tkr<td|sH|sH|rb| tt d fv rbtd| d S )Nz)items can only be used when type is arrayz'TYPE_ARRAY requires the items attributez,pattern can only be used when type is stringz9[format, enum, pattern] can only be applied to primitive )
TYPE_ARRAYrm   TYPE_STRINGTYPE_OBJECT)r4   formatenumpatternrH   Z	_obj_typer'   r'   r(   _check_typew  s    r   c                       s   e Zd Zd fdd	Z  ZS )ItemsNc                    sd   t t| jf i | |dus&J d|| _|| _|| _|| _|| _|   t	|||||| j
 dS )a  Used when defining an array :class:`.Parameter` to describe the array elements.

        :param str type: type of the array elements; must not be ``object``
        :param str format: value format, see OpenAPI spec
        :param list enum: restrict possible values
        :param str pattern: pattern if type is ``string``
        :param .Items items: only valid if `type` is ``array``
        Ntype is required!)r2   r   r.   r4   r   r   r   items_r5   r   r:   )r7   r4   r   r   r   rH   rp   r9   r'   r(   r.     s    	zItems.__init__)NNNNNrq   r'   r'   r9   r(   r     s   r   c                	       s   e Zd Zd fdd	Z  ZS )	ParameterNc                    s   t t| jf i | || _|| _|| _|| _|| _|| _|| _	|| _
|	| _|
| _|| _|   |sh|rp|rx|rxtd|rt|tr|  | d tkr|dusJ dd| _| d tkr|durtd| |r|stdt||||	|
| j dS )	a  Describe parameters accepted by an :class:`.Operation`. Each parameter should be a unique combination of
        (`name`, `in_`). ``body`` and ``form`` parameters in the same operation are mutually exclusive.

        :param str name: parameter name
        :param str in_: parameter location
        :param str description: parameter description
        :param bool required: whether the parameter is required for the operation
        :param schema: required if `in_` is ``body``
        :type schema: Schema or SchemaRef
        :param str type: parameter type; required if `in_` is not ``body``; must not be ``object``
        :param str format: value format, see OpenAPI spec
        :param list enum: restrict possible values
        :param str pattern: pattern if type is ``string``
        :param .Items items: only valid if `type` is ``array``
        :param default: default value if the parameter is not provided; must conform to parameter type
        zCeither schema or type are required for Parameter object (not both)!inFz!path parameter cannot be optionalTNz6schema can only be applied to a body Parameter, not %sz3default can only be applied to a non-body Parameter)r2   r   r.   rn   in_rv   requiredschemar4   r   r   r   r   defaultr5   rm   rV   Schema_remove_read_onlyIN_PATHIN_BODYr   r:   )r7   rn   r   rv   r   r   r4   r   r   r   rH   r   rp   r9   r'   r(   r.     s2    zParameter.__init__)	NNNNNNNNNrq   r'   r'   r9   r(   r     s     r   c                       s*   e Zd ZdZd fdd	Zdd Z  ZS )r   r'   Nc                    s   t t| jf i | |	du s&|	du r.td|s:J d|| _|| _t|	| _|| _t|| _	|| _
|| _|| _|| _|
| _|| _|| _|   |s|dur|tkrtdt|||||
| j dS )a  Describes a complex object accepted as parameter or returned as a response.

        :param str title: schema title
        :param str description: schema description
        :param str type: value type; required
        :param str format: value format, see OpenAPI spec
        :param list enum: restrict possible values
        :param str pattern: pattern if type is ``string``
        :param properties: object properties; required if `type` is ``object``
        :type properties: dict[str,Schema or SchemaRef]
        :param additional_properties: allow wildcard properties not listed in `properties`
        :type additional_properties: bool or Schema or SchemaRef
        :param list[str] required: list of required property names
        :param items: type of array items, only valid if `type` is ``array``
        :type items: Schema or SchemaRef
        :param default: only valid when insider another ``Schema``\ 's ``properties``;
            the default value of this property if it is not provided, must conform to the type of this Schema
        :param read_only: only valid when insider another ``Schema``\ 's ``properties``;
            declares the property as read only - it must only be sent as part of responses, never in requests
        TFz^the `required` attribute of schema must be an array of required property names, not a boolean!r   Nz&only object Schema can have properties)r2   r   r.   rm   rt   rv   r   r   r4   
propertiesadditional_propertiesr   r   r   r   	read_onlyr   r5   r   r   r:   )r7   rt   rv   r4   r   r   r   r   r   r   rH   r   r   rp   r9   r'   r(   r.     s(    

zSchema.__init__c                 C   s   |  dd d S )NZreadOnly )popr^   r'   r'   r(   r     s    zSchema._remove_read_only)NNNNNNNNNNNN)rB   rg   rh   OR_REFr.   r   rk   r'   r'   r9   r(   r     s
     -r   c                       sD   e Zd ZedZd fdd	Zdd Z fddZd	d
 Z	  Z
S )_Refz #/(?P<scope>.+)/(?P<name>[^/]+)$Fc                    sr   t t|   t| tkr"J ddj||d}|sh|||}t||shJ |djt|j|jd || _dS )a  Base class for all reference types. A reference object has only one property, ``$ref``, which must be a JSON
        reference to a valid object in the specification, e.g. ``#/definitions/Article`` to refer to an article model.

        :param .ReferenceResolver resolver: component resolver which must contain the referenced object
        :param str name: referenced object name, e.g. "Article"
        :param str scope: reference scope, e.g. "definitions"
        :param type[.SwaggerDict] expected_type: the expected type that will be asserted on the object found in resolver
        :param bool ignore_unresolved: do not throw if the referenced object does not exist
        z do not instantiate _Ref directlyz#/{scope}/{name})scopern   z  is a {actual}, not a {expected})actualexpectedN)	r2   r   r.   r4   r   r   rV   rB   r!   )r7   resolverrn   r   expected_typeignore_unresolvedref_namer]   r9   r'   r(   r.     s    

z_Ref.__init__c                 C   s(   | j | j}|j|d|ddS )zGet the object targeted by this reference from the given component resolver.

        :param .ReferenceResolver resolver: component resolver which must contain the referenced object
        :returns: the target object
        rn   r   )r   )ref_name_rematchr!   
getdefaultgroup)r7   r   Z	ref_matchr'   r'   r(   resolve  s    z_Ref.resolvec                    s*   |dkrt t| ||S td| d S )Nr"   z2only $ref can be set on Reference objects (not %s))r2   r   __setitem__NotImplementedErrorr=   r9   r'   r(   r     s    z_Ref.__setitem__c                 C   s   t dd S )Nz*cannot delete property of Reference object)r   )r7   r>   r'   r'   r(   __delitem__   s    z_Ref.__delitem__)F)rB   rg   rh   recompiler   r.   r   r   r   rk   r'   r'   r9   r(   r     s
   
	r   c                       s   e Zd Zd fdd	Z  ZS )	SchemaRefFc                    s*   t |jv sJ tt| ||t t| dS )a?  Adds a reference to a named Schema defined in the ``#/definitions/`` object.

        :param .ReferenceResolver resolver: component resolver which must contain the definition
        :param str schema_name: schema name
        :param bool ignore_unresolved: do not throw if the referenced object does not exist
        N)SCHEMA_DEFINITIONSscopesr2   r   r.   r   )r7   r   Zschema_namer   r9   r'   r(   r.   %  s    zSchemaRef.__init__)Frq   r'   r'   r9   r(   r   $  s   r   c                 C   s   t | tr| |S | S )zResolve `ref_or_obj` if it is a reference type. Return it unchanged if not.

    :param ref_or_obj: object to dereference
    :type ref_or_obj: SwaggerDict or _Ref
    :param resolver: component resolver which must contain the referenced object
    )rV   r   r   )Z
ref_or_objr   r'   r'   r(   resolve_ref3  s    

r   c                       s   e Zd Zd fdd	Z  ZS )	ResponsesNc                    sN   t t| jf i | | D ]\}}|dur|| t|< q|| _|   dS )a4  Describes the expected responses of an :class:`.Operation`.

        :param responses: mapping of status code to response definition
        :type responses: dict[str or int,Response]
        :param Response default: description of the response structure to expect if another status code is returned
        N)r2   r   r.   rH   rZ   r   r5   )r7   r   r   rp   statusresponser9   r'   r(   r.   @  s    zResponses.__init__)Nrq   r'   r'   r9   r(   r   ?  s   r   c                       s   e Zd Zd fdd	Z  ZS )ResponseNc                    sJ   t t| jf i | || _|| _|| _|   |rFt|trF|	  dS )aw  Describes the structure of an operation's response.

        :param str description: response description
        :param schema: structure of the response body
        :type schema: Schema or SchemaRef or rest_framework.serializers.Serializer
            or type[rest_framework.serializers.Serializer]
        :param dict examples: example bodies mapped by mime type
        N)
r2   r   r.   rv   r   examplesr5   rV   r   r   )r7   rv   r   r   rp   r9   r'   r(   r.   P  s    	zResponse.__init__)NNrq   r'   r'   r9   r(   r   O  s   r   c                   @   s   e Zd ZdZdd Zdd Zdd Zdd	d
ZdddZdddZ	d ddZ
d!ddZdd Zedd Zdd Zdd Zdd ZdS )"ReferenceResolvera  A mapping type intended for storing objects pointed at by Swagger Refs.
    Provides support and checks for different reference scopes, e.g. 'definitions'.

    For example:

    ::

        > components = ReferenceResolver('definitions', 'parameters')
        > definitions = components.with_scope('definitions')
        > definitions.set('Article', Schema(...))
        > print(components)
        {'definitions': OrderedDict([('Article', Schema(...)]), 'parameters': OrderedDict()}
    c                 O   sR   | dd}|stdt | _d| _|D ]"}t|ts@J dt | j|< q*dS )zb
        :param str scopes: an enumeration of the valid scopes this resolver will contain
        
force_initFa  Creating an instance of ReferenceResolver almost certainly won't do what you want it to do.
See https://github.com/axnsan12/drf-yasg/issues/211, https://github.com/axnsan12/drf-yasg/issues/271, https://github.com/axnsan12/drf-yasg/issues/325.
Pass `force_init=True` to override this.Nzscope names must be strings)r   rm   r   _objects_force_scoperV   rZ   )r7   r   kwargsr   r   r'   r'   r(   r.   q  s    zReferenceResolver.__init__c                 C   s2   || j v sJ d| tdd}| j|_||_|S )a   Return a view into this :class:`.ReferenceResolver` whose scope is defaulted and forced to `scope`.

        :param str scope: target scope, must be in this resolver's `scopes`
        :return: the bound resolver
        :rtype: .ReferenceResolver
        zunknown scope %sT)r   )r   r   r   r   )r7   r   retr'   r'   r(   
with_scope  s
    
zReferenceResolver.with_scopec                 C   sH   | j p|}|d ur*| j r*|| j ks*J d|r8|| jv sDJ d| |S )Nzcannot override forced scopezinvalid scope %sr   r   )r7   r   Z
real_scoper'   r'   r(   _check_scope  s
    
zReferenceResolver._check_scopeNc                 C   sJ   |  |}|dusJ d|| j| vs8J d||f || j| |< dS )zSet an object in the given scope, raise an error if it already exists.

        :param str name: reference name
        :param obj: referenced object
        :param str scope: reference scope
        Nz&referenced objects cannot be None/nullz#/%s/%s already existsr   r   )r7   rn   r]   r   r'   r'   r(   set  s    
zReferenceResolver.setc                 C   s   |  |}t|s$J dt|j | |d|}|du r| }| |d|}|dus^J d|du rv| ||| n||krtd| |}|S )zSet an object in the given scope only if it does not exist.

        :param str name: reference name
        :param function maker: object factory, called only if necessary
        :param str scope: reference scope
        z%setdefault expects a callable, not %sNz;maker returned None; referenced objects cannot be None/nullzOduring setdefault, maker for %s inserted a value and returned a different value)r   callabler4   rB   r   r   loggerdebug)r7   rn   makerr   r   r?   r'   r'   r(   
setdefault  s    
zReferenceResolver.setdefaultc                 C   s6   |  |}|| j| v s(J d||f | j| | S )zGet an object from the given scope, raise an error if it does not exist.

        :param str name: reference name
        :param str scope: reference scope
        :return: the object
        z#/%s/%s is not definedr   r7   rn   r   r'   r'   r(   r     s    
zReferenceResolver.getc                 C   s   |  |}| j| ||S )zGet an object from the given scope or a default value if it does not exist.

        :param str name: reference name
        :param default: the default value
        :param str scope: reference scope
        :return: the object or `default`
        )r   r   r   )r7   rn   r   r   r'   r'   r(   r     s    
zReferenceResolver.getdefaultc                 C   s   |  |}|| j| v S )zCheck if an object exists in the given scope.

        :param str name: reference name
        :param str scope: reference scope
        :return: True if the object exists
        :rtype: bool
        r   r   r'   r'   r(   has  s    
zReferenceResolver.hasc                 C   s    | j rt| j| j  S t| jS r*   )r   re   r   r^   r'   r'   r(   __iter__  s    zReferenceResolver.__iter__c                 C   s   | j r| j gS t| j S r*   )r   listr   keysr^   r'   r'   r(   r     s    zReferenceResolver.scopesc                 C   s    | j r| j| j   S | j S r*   )r   r   r   r^   r'   r'   r(   r     s    zReferenceResolver.keysc                 C   s    | j r| j| j  | S | j| S r*   r   rC   r'   r'   r(   __getitem__  s    zReferenceResolver.__getitem__c                 C   s   t t| S r*   )rZ   dictr^   r'   r'   r(   __str__  s    zReferenceResolver.__str__)N)N)N)NN)N)rB   rg   rh   ri   r.   r   r   r   r   r   r   r   r   r   r   r   r   r   r'   r'   r'   r(   r   b  s   





r   )Jcollectionsloggingr   urllib.parseparser}   r   Zdjango.urlsr   Zdjango.utils.functionalr   Z
inflectionr   utilsr   r   r	   r
   rX   ImportError	getLoggerrB   r   r   r   ZTYPE_NUMBERZTYPE_INTEGERZTYPE_BOOLEANr   Z	TYPE_FILEZFORMAT_DATEZFORMAT_DATETIMEZFORMAT_PASSWORDZFORMAT_BINARYZFORMAT_BASE64ZFORMAT_FLOATZFORMAT_DOUBLEZFORMAT_INT32ZFORMAT_INT64ZFORMAT_EMAILZFORMAT_IPV4ZFORMAT_IPV6Z
FORMAT_URIZFORMAT_UUIDZFORMAT_SLUGZFORMAT_DECIMALr   r   ZIN_QUERYZIN_FORMZ	IN_HEADERr   r)   r1   r,   rl   rr   rs   rz   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r'   r'   r'   r(   <module>   s~   

W>%/6(
