o
    [d                     @   sj  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dl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 d dlmZ d d	lmZ d d
lmZ d dlmZ zd dlmZ W n eyw   dZY nw ddlmZm Z  ddl!m"Z" ddl!m#Z# ddl!m$Z$ dd Z%dd Z&	dWddZ'			dXddZ(dd Z)			dYddZ*dZd d!Z+d"d# Z,d$d% Z-d&d' Z.d[d)d*Z/d[d+d,Z0d-d. Z1d/d0 Z2d\d2d3Z3d]d5d6Z4dZd7d8Z5d9d: Z6d;d< Z7dWd=d>Z8		d^d?d@Z9dAdB Z:dCdD Z;dEdF Z<G dGdH dHe=Z>G dIdJ dJe>Z?G dKdL dLe?Z@dMdN ZAdOdP ZBdQdR ZCdSeDdTefdUdVZEdS )_    N)string_types	text_type)deepcopywrapsimport_module)OrderedDictdefaultdict)Response)abort)current_app)request)
MethodView)methods   )OPTIONAL_FIELDSDEFAULT_FIELDS)SwaggerView)convert_schemas)Schemac                 C   sb   |  D ]*\}}t|tr| |i }t|| qt|tr*| |g }|| q|| |< qdS )zk
    Update target dictionary with values from the source, recursively.
    List items will be merged.
    N)items
isinstancedict
setdefaultmerge_specslistextend)targetsourcekeyvaluenode r#   U/home/www/bk.finsightngr.online/venv20/lib/python3.10/site-packages/flasgger/utils.pyr   "   s   


r   c           
      C   s   t |jdd}|jdpt}|jd}|j  ttj	 |||j
|}dd |D }W d    n1 s:w   Y  |D ]&}|dg D ]}|di d	}	|	d urf|	 |  krf|    S qIqAd S )
Nignore_verbs)ZHEADZOPTIONSoptional_fieldsopenapic                 s   s.    | ]\}}|D ]\}}|d ur|V  qqd S Nr#   ).0_verbsswagr#   r#   r$   	<genexpr>B   s    z#get_schema_specs.<locals>.<genexpr>
parametersschemaid)setconfiggetr   appapp_context	get_specsr   Zurl_mapZ
iter_rules	sanitizerlower)
	schema_idZswaggerr%   r&   openapi_versionspecsZswagsr,   dZd_schema_idr#   r#   r$   get_schema_specs3   s.   
r=   c                  C   sX  g }| D ]}t j|j }t }	t|}
|j|D ]i}|
s5t|r5|jp'dg|_||jv r4||	| < qt	|dd d ur}t
|jtrU||jv rT| }t	|j||	|< qtd ur{tdd |jD }||v rz|j|jd}|rzt	t||	| < qt||	| < qg }|	 D ]\}}|jdd }|
s|rt|drt	|dd }n|rt|drt	|dd }|d u rt	||d }|d u r|
rqtd	|i }i }d
}t	|dd ri }t|tt|j| |}d}t	|dd }|r#t|tr#i }|g d }|D ]}t	||}|r|||< q|di }|t|| |}d}|r^|r6tj ||j|jd }n
tj ||jd }tj!|r^t|drP|j"n|}t#|dd t#|d| t$|||j|d\}}}t%|rx||&di d< n||d< |rt|| d}|r|r||d< |r||d< |'||f q|r|'||f q|S )NZGETr   c                 s   s    | ]}|j V  qd S r(   )method)r)   mr#   r#   r$   r-   a   s    zget_specs.<locals>.<genexpr> 
view_classverbdispatch_requestz$Cannot detect view_func for rule {0}F
specs_dictT)r.   definitionsZ	responsessummarydescriptionrE   z.yml__func__	swag_typeyml	swag_path)endpointrB   
componentsschemasrF   rG   )(r   Zview_functionsrL   r   is_valid_method_viewr   
differencehas_valid_dispatch_view_docsr8   getattrr   r1   rA   fmr_methodsreplace__name__	TypeErrorr   __dict__r3   hasattrRuntimeErrorformatr   r   r   rD   
issubclassr   updateospathjoinisfilerH   setattrparse_docstringis_openapi3r   append) Zrulesr%   r&   r7   r:   Zdoc_dirr;   ZrulerL   r   Zis_mvrB   Zendpoint_methodsZ
proxy_verbr+   r>   klassr,   Zswag_defZswagged
definitionrA   Zapispec_swagZapispec_attrsattrr!   Zapispec_definitions	file_pathfuncZdoc_summaryZdoc_descriptionZdoc_swagr#   r#   r$   r6   M   s   








r6   Fc
              
      sR   dd 
fdd
fdd	dd  	
f
d	d
}
|
S )a  
    Takes a filename.yml, a dictionary or object and loads swagger specs.

    :param specs: a filepath, a dictionary or an object
    :param filetype: yml or yaml (json and py to be implemented)
    :param endpoint: endpoint to build definition name
    :param methods: method to build method based specs
    :param validation: perform validation?
    :param schema_id: Definition id ot name to use for validation
    :param data: data to validate (default is request.json)
    :param definition: alias to schema_id
    :param validation_function:
        custom validation function which takes the positional
        arguments: data to be validated at first and schema to validate
        against at second
    :param validation_error_handler: custom function to handle
        exceptions thrown when validating which takes the exception
        thrown as the first, the data being validated as the second and
        the schema being used to validate as the third argument
    c                 S   sl   zddl m} t||rt|}W n	 ty   Y nw |ds4t| ds*t| | _t	j
| j|}|S |S )Nr   Path/	root_path)pathlibrk   r   strImportError
startswithrX   get_root_pathrm   r]   r^   r_   )functionfilepathrk   resr#   r#   r$   resolve_path   s   



zswag_from.<locals>.resolve_pathc                    s   | }p| dd | _ srt| dsi | _ s$s$|| _d S  r<r<D ]}d | }|| j|< q*d S  rGsG|| j < d S rW sYD ]}|| j| < qMd S d S d S )N.
swag_paths{}_{})splitrI   rX   ry   rK   rZ   r8   )rs   final_filepathrB   r    )rL   filetyper   rv   r;   r#   r$   set_from_filepath   s&   


z$swag_from.<locals>.set_from_filepathc                    s
    | _ d S r(   )rD   )rs   )r;   r#   r$   set_from_specs_dict
  s   
z&swag_from.<locals>.set_from_specs_dictc                 S   sB   t | t}zddlm} t | |}|p|W S  ty    | Y S w )z; Returns True if specs is a string or pathlib.Path
        r   rj   )r   r   rn   rk   rp   )r;   Zis_str_pathrk   Zis_py3_pathr#   r#   r$   is_path  s   


zswag_from.<locals>.is_pathc              	      s~   r  t  dd }t  dd }|p|t  dd dttr,  dit  	
fdd}|S )NrK   ry   rm   )rt   rootr;   c                     s2   du rt  p	fd | i |S )NT)validation_functionvalidation_error_handler)validate)argskwargs)datarf   rs   r9   validate_args
validationr   r   r#   r$   wrapper'  s   z-swag_from.<locals>.decorator.<locals>.wrapper)rR   r   r   r   )rs   rK   ry   r   )
r   rf   r   r9   r~   r   r;   r   r   r   )rs   r   r$   	decorator  s   


zswag_from.<locals>.decoratorr#   )r;   r}   rL   r   r   r9   r   rf   r   r   r   r#   )r   rf   rL   r}   r   r   rv   r9   r~   r   r;   r   r   r   r$   	swag_from   s   r   c              	   C   sl  t jtjd }i }|  D ]\}}t|tr!t|||||< q|dkrt	|dkrS|
drS|}|ddd D ]}|| }q;t|trOt|||  S |  S t	|dkrd|d dkrd|| }	n|d | }	t j|	}t|	2}
|
 }|d}|dkr|d	 }nd}t||d }|}t|trt|||}W d   n1 sw   Y  q|||< q|S )
zd TODO: add dev docs

    :param schema:
    :param relative_path:
    :param swag:
    :return:
    r   $ref   z#/rl   r   N---   )r]   r^   dirnamesysargvr   r   r   __replace_reflenrq   r{   openreadrfindyaml	safe_load)r/   relative_pathr,   absolute_pathZ	new_valuer    r!   contentr0   Zfile_ref_pathfileZfile_contentZcomment_indexr#   r#   r$   r   7  sB   







r   Tc
              
   C   s  |p|}|du r|du rt tddd | du rtj} nt| r#|  } | s/|r/t tddd tj dd}
tj }|dur|sczt	
 d	 }tjtj|d	 }W qi tyb   d}Y qiw tj|}|d
svtj||}n|}t|}|d}t||dkr|ndd }nt|}dd |dg D }i }i }t||
||	d}|du r|D ]}|ddkr|di d}|r|d
d } qq|du r|r|d d}|D ]}|d  | kr| }q|||d < q|t|v rt||}||d< | D ]\}}d|v r|d= q|du r$tj}tjtj d }|du r5|}ntj|}t!|||}z|| | W dS  tyz } z$|dur^||| | nt tt"|dd W Y d}~dS W Y d}~dS d}~ww )a  
    This method is available to use YAML swagger definitions file
    or specs (dict or object) to validate data against its jsonschema.

    example:
        validate({"item": 1}, 'item_schema', 'defs.yml', root=__file__)
        validate(request.json, 'User', specs={'definitions': {'User': ...}})

    :param data: data to validate, by default is request.json
    :param schema_id: The definition id to use to validate (from specs)
    :param filepath: definition filepath to load specs
    :param root: root folder (inferred if not provided), unused if path
        starts with `/`
    :param definition: Alias to schema_id (kept for backwards
        compatibility)
    :param specs: load definitions from dict or object passed here
        instead of a file.
    :param validation_function: custom validation function which takes
        the positional arguments: data to be validated at first and
        schema to validate against at second
    :param validation_error_handler: custom function to handle
        exceptions thrown when validating which takes the exception
        thrown as the first, the data being validated as the second and
        the schema being used to validate as the third argument
    :param require_data: is the data param required?
    Nz'Filepath or specs is needed to validatei  )statuszNo data to validatei  rw   r*   r   rl   r   r   c                 S   s   g | ]	}| d r|qS r/   )r3   )r)   itemr#   r#   r$   
<listcomp>  s    zvalidate.<locals>.<listcomp>r.   )rL   rB   r:   inbodyr/   r   rx   r0   rE   )#r   r   r   jsoncallablerL   r8   rT   r>   inspectstackr]   r^   r   abspath	Exceptionrq   r_   load_from_filefindr   r   copyr   r3   extract_definitionsr{   extract_schemar   
jsonschemar   r   r   r   ro   )r   r9   rt   r   rf   r;   r   r   require_datar:   rL   rB   Z
frame_infor|   full_docZ
yaml_startr,   paramsrE   Zmain_defZraw_definitionsparamZdefir    r!   r   r   errr#   r#   r$   r   c  s   


 






"r   c           
      C   s   |pg }|pg }|   5 |D ]}t|ttfr|\}}n	|}|jdd}|jj||d q|D ]}|j|d q1W d   n1 sDw   Y  |	 }t
|}	|	S )z
    Converts apispec object in to flasgger definitions template
    :param app: Current app
    :param spec: apispec.APISpec
    :param definitions: a list of [Schema, ..] or [('Name', Schema), ..]
    :param paths: A list of flask views
    r   r@   r   )viewN)r5   r   tupler   rU   rT   rM   r/   r^   Zto_dictordered_dict_to_dict)
r4   specrE   pathsrf   namer/   r^   Z	spec_dictretr#   r#   r$   apispec_to_template  s    

r   c                 C   sN   i }t | }| D ]\}}t|trt|}t|tr t|}|||< q
|S )z1
    Converts inner OrderedDict to bare dict
    )r   r   r   r	   r   r   )r<   r   Znew_dkvr#   r#   r$   r     s   


r   c                 C   s   t j| d S )zRemove all file ending suffixesr   )r]   r^   splitextfpathr#   r#   r$   remove_suffix  s   r   c                 C   s   |  dod| vS )zNaive Python module filtererz.py__)endswithr   r#   r#   r$   is_python_file  s   r   	examples/c                    s   | dd  fdd| D S )z*nix to python module pathrl   rw   c                    s   g | ]} | qS r#   r#   )r)   basenameZexampler#   r$   r         zpathify.<locals>.<listcomp>)rT   )	basenamesexamples_dirr#   r   r$   pathify  s   r   c                 C   sF   t | }dd |D }dd |D }dd t|D }dd |D S )zAll example modulesc                 S   s   g | ]}t |r|qS r#   )r   r)   fr#   r#   r$   r   #  s    z get_examples.<locals>.<listcomp>c                 S      g | ]}t |qS r#   )r   r   r#   r#   r$   r   $  r   c                 S   r   r#   r   r)   moduler#   r#   r$   r   %  r   c                 S   s    g | ]}t |d ddur|qS )r4   N)rR   r   r#   r#   r$   r   &  s    )r]   listdirr   )r   Z	all_filesZpython_filesr   modulesr#   r#   r$   get_examples   s   
r   c                 C   s&   |  dd }|dd }||fS )z1
    If `file:` is provided import the file.
    file:r@   rw   rx   )rT   stripr{   )r   rK   rI   r#   r#   r$   get_path_from_doc,  s   r   c                 C   s   | S )z$
    TODO: convert json to yaml
    r#   )r   r#   r#   r$   json_to_yaml5  s   r   rJ   c                 C   s  |dvrt dz#t| }tj| |d}| W  d   W S 1 s$w   Y  W dS  ty   tj|p<tj	t
| } z&t| }tj| |d}| W  d   W  Y S 1 s]w   Y  W Y dS  ty   | dtjdtj} | |ptj	t
dtjdd }tj|d	 }|jr|jd
d}ntdtj|tj|dd } t| }| W  d    Y  Y S 1 sw   Y  Y Y dS w w )z#
    Load specs from YAML file
    )r   rJ   z$Currently only yaml or yml supported)encodingNrl   \r@   r   r   z/__init__.pyzPackage does not have origin)AttributeErrordetect_by_bomcodecsr   r   IOErrorr]   r^   r_   r   __file__rT   sepr{   	importlibutil	find_spechas_locationoriginrY   )rK   rI   rm   encZ	yaml_filer^   Zpackage_specZsite_packager#   r#   r$   r   <  sB   (.
0r   utf-8c                    s   t | d}|d W d    n1 sw   Y  dtjffdtjtjffdtjtjfffD ]\}}t fdd|D rB|  S q/|S )Nrb   z	utf-8-sigzutf-16zutf-32c                 3   s    | ]}  |V  qd S r(   rq   )r)   bomrawr#   r$   r-   n  s    z detect_by_bom.<locals>.<genexpr>)	r   r   r   BOM_UTF8BOM_UTF16_LEBOM_UTF16_BEBOM_UTF32_LEBOM_UTF32_BEany)r^   defaultr   r   Zbomsr#   r   r$   r   g  s   

r   c                 C   st  d\}}}d}t | dd}t | dd}	t | dd}
t| }d}|dur+t||	}d}n'|
durMd	|||| fD ]}||
v rIt|
| |	} qJq:d}nt| }|r|d
rvt| dsa|| _	t
|\}}	tj| j	|}t||	}d}t||}|d}|dkr|d}|dkr||d| }|||d | }t||d d }n
|rt|}n|}|||fS )z2
    Gets swag data for method/view docstring
    )NNNNrK   rI   rJ   ry   FTrz   r   rm   r   rx   
r   r   )rR   rr   r   rZ   r8   r   getdocrq   rX   rm   r   r]   r^   r_   parse_importsr   r   r   )objprocess_docrL   rB   
first_lineZother_linesr,   r   rK   rI   ry   rm   	from_filer    doc_filepathyaml_sepZ	line_feedr#   r#   r$   rb   s  sR   









rb   c              	   C   s^   zt j| jd }W n ttfy(   t| ddr!t| j Y S t	
| }Y nw t j|S )z:
    Get file path for object and returns its dirname
    r   __wrapped__N)r]   r^   r   __globals__KeyErrorr   rR   rr   r   r   getfiler   )r   filenamer#   r#   r$   rr     s   rr   c           	      C   s   d\}}d}t | dd}t | dd}|durt||}nt| }|rm|drEt| ds2t| | _t|\}}t	j
| j|}t||}|d}|d	kri|rZ||d|d
  nd}t||d }||fS ||}||fS )zC
    Gets swag data from docstring for class based definitions
    NNNrK   rI   rJ   r   rm   r   rx   r   )rR   r   r   r   rq   rX   rr   rm   r   r]   r^   r_   r   r   r   )	r   r   Z	doc_linesr,   r   rK   rI   r   r   r#   r#   r$   parse_definition_docstring  s4   





r  c           	      C   s   t d}|| }|rF| }|| dd| d }|d}|dr*t|}nt||d}|ddd|  }|j	|| dd} t
| S | S )	z=
    Supports `import: otherfile.yml` in docstring specs
    zimport: "(.*)"r   r   r   rl   )rm    )count)recompilesearchstartr   grouprq   r   rT   subr   )	r   rm   ZregexZimport_propr  Z
spaces_numrt   Zimported_docZindented_imported_docr#   r#   r$   r     s   




r   c              	      sF   pt j  pt j  dd  fdd}du r$dt }| D ]w}t|ds4td|d	}	|	dur|	d
}
|
dur|rSd	 |
 |	d
< }
|
|	 d}trad}nd}dd	||
i}dkrt||d	< n|| |d	= |	d}|dur|t| d  7 }|||	7 }|||7 }q)|S )z
    Since we couldn't be bothered to register models elsewhere
    our definitions need to be extracted from the parameters.
    We require an 'id' field for the schema to be correctly
    added to the definitions list.
    rw   r*   c                    s>   g }|  d}|durd|v r|t|gd  7 }|S )z9
        Extracts definitions identified by `id`
        r   Nr/   r   )r3   r   )r   r   r   rL   levelr:   
prefix_idsrB   r#   r$   _extract_array_defs  s   
z0extract_definitions.<locals>._extract_array_defsNr   r3   z#definitions must be a list of dictsr/   r0   z{}_{}_{}z#/components/schemas/z#/definitions/r   z{}{}
propertiesr   )r   rL   r8   r>   rT   r   rR   rY   r3   rZ   rd   rc   r\   r   values)Zalistr  rL   rB   r  r:   r  Zdefsr   r/   r9   Zref_pathrefr  r#   r  r$   r     sJ   






r   c                 C   s2   | j dd}|ot|dot| dot|djS )z6
    Return True if dispatch_request is swaggable
    rA   NrC   r   )rW   r3   rX   rR   __doc__rL   re   r#   r#   r$   rQ   E  s   
rQ   c                 C   s0   | j dd}zt|tW S  ty   Y dS w )z*
    Return True if obj is MethodView
    rA   NF)rW   r3   r[   r   rV   r  r#   r#   r$   rO   O  s   rO   c                 C   s   dd |   D S )z
    Identify vendor extension fields and extract them into a new dictionary.
    Examples:
        >>> get_vendor_extension_fields({'test': 1})
        {}
        >>> get_vendor_extension_fields({'test': 1, 'x-test': 2})
        {'x-test': 2}
    c                 S   s    i | ]\}}| d r||qS )zx-r   )r)   r   r   r#   r#   r$   
<dictcomp>c  s     z/get_vendor_extension_fields.<locals>.<dictcomp>)r   )mappingr#   r#   r$   get_vendor_extension_fieldsZ  s   	r  c                   @   s   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zed d! Zd"S )#
StringLikez
    Class to mimic the behavior of a regular string. Classes that inherit (or
    mixin) this class must implement the `__str__` magic method. Whatever that
    method returns is used by the various string-like methods.
    c                 C   s&   |  | }t||rt||S t|)z
        Forwards any non-magic methods to the resulting string's class. This
        allows support for string methods like `upper()`, `lower()`, etc.
        )r   rX   rR   r   )selfrg   stringr#   r#   r$   __getattr__m  s   


zStringLike.__getattr__c                 C      t | | S r(   )r   r   r  r#   r#   r$   __len__w     zStringLike.__len__c                 C   s   |  | | S r(   r   )r  r    r#   r#   r$   __getitem__z  r!  zStringLike.__getitem__c                 C   r  r(   )iterr   r  r#   r#   r$   __iter__}  r!  zStringLike.__iter__c                 C   s   ||  | v S r(   r"  )r  r   r#   r#   r$   __contains__  r!  zStringLike.__contains__c                 C   s   |  | | S r(   r"  r  otherr#   r#   r$   __add__  r!  zStringLike.__add__c                 C   s   ||  |  S r(   r"  r'  r#   r#   r$   __radd__  r!  zStringLike.__radd__c                 C   s   |  | | S r(   r"  r'  r#   r#   r$   __mul__  r!  zStringLike.__mul__c                 C   s   ||  |  S r(   r"  r'  r#   r#   r$   __rmul__  r!  zStringLike.__rmul__c                 C   s   |  | |k S r(   r"  r'  r#   r#   r$   __lt__  r!  zStringLike.__lt__c                 C   s   |  | |kS r(   r"  r'  r#   r#   r$   __le__  r!  zStringLike.__le__c                 C   s   |  | |kS r(   r"  r'  r#   r#   r$   __eq__  r!  zStringLike.__eq__c                 C   s   |  | |kS r(   r"  r'  r#   r#   r$   __ne__  r!  zStringLike.__ne__c                 C   s   |  | |kS r(   r"  r'  r#   r#   r$   __gt__  r!  zStringLike.__gt__c                 C   s   |  | |kS r(   r"  r'  r#   r#   r$   __ge__  r!  zStringLike.__ge__c                 C   s   t S r(   r"  r  r#   r#   r$   r     s   zStringLike.text_typeN)rU   
__module____qualname__r  r  r   r#  r%  r&  r)  r*  r+  r,  r-  r.  r/  r0  r1  r2  propertyr   r#   r#   r#   r$   r  f  s&    
r  c                   @   s    e Zd ZdZdd Zdd ZdS )
LazyStringze
    A lazy string *without* caching. The resulting string is regenerated for
    every request.
    c                 C   s
   || _ dS )zy
        Creates a `LazyString` object using `func` as the delayed closure.
        `func` must return a string.
        N)_funcr  ri   r#   r#   r$   __init__  s   
zLazyString.__init__c                 C   s   |  |  S )z,
        Returns the actual string.
        )r   r7  r  r#   r#   r$   __str__  s   zLazyString.__str__N)rU   r3  r4  r  r9  r:  r#   r#   r#   r$   r6    s    r6  c                       s(   e Zd ZdZ fddZdd Z  ZS )CachedLazyStringz%
    A lazy string with caching.
    c                    s   t t| | d| _dS )zL
        Uses `__init__()` from the parent and initializes a cache.
        N)superr;  r9  _cacher8  	__class__r#   r$   r9    s   
zCachedLazyString.__init__c                 C   s   | j s| |  | _ | j S )zB
        Returns the actual string and caches the result.
        )r=  r   r7  r  r#   r#   r$   r:    s   zCachedLazyString.__str__)rU   r3  r4  r  r9  r:  __classcell__r#   r#   r>  r$   r;    s    r;  c                    s   t   fdd}|S )Nc                     s@  | dds | i |S | d }i }t D ]\}}| ||||< q|j D ]`\}}t|trX| }| }|d D ]	}	|d |	 q=|d |d  t	|||}q)t|t
rx|dddd	}
d
| | d v rpd|
d< |d |
 q)t|tr|d |dddd	 q)||_t| } || d< t| }  | i |S )Nr,   Fr   r.   rE   r^   integerT)r   r   typerequiredzint(signed=True):r   Zminimumr  )popr   r   __annotations__r[   r   to_specs_dictrd   r\   validate_annotationintro   rD   r   r   )r   r   rs   r;   r    r!   variable
annotationr   rowr?   r   r#   r$   r     sF   



z swag_annotation.<locals>.wrapperr   r   r   r#   rL  r$   swag_annotation  s   ,rN  c                    s    fdd}|S )Nc                    s   t   fdd}|S )Nc                     sh    j r)d } jdkrttj}n jdkrtjrtj}t|   j	 j
 jd | i ||iS )Nqueryr   )r;   r   r   r   )Zswag_validateZswag_inr   r   r   Zis_jsonr   r   rF  Zswag_validation_functionZswag_validation_error_handlerZswag_require_data)r   r   payload)anr   varr#   r$   r     s   
	z7validate_annotation.<locals>.decorator.<locals>.wrapperr   rM  rQ  rR  rL  r$   r     s   z&validate_annotation.<locals>.decoratorr#   )rQ  rR  r   r#   rS  r$   rG     s   rG  c                 C   s   | ot | dd dkS )z.
    Returns True if openapi_version is 3
    rw   r   3)ro   r{   )r:   r#   r#   r$   rc     s   rc   r   returnc                 C   s<   |  dd}t|r|  di  dttS |  dttS )z?
    Returns schema resources according to openapi version
    r'   NrM   rN   rE   )r3   rc   r
   r   )r   r:   r#   r#   r$   r   $  s   
r   r(   )
NNNNFNNNNN)
NNNNNNNNTNr  )r   )rJ   N)r   )NNNFN)Fr   r   r   r   r]   r  r   r   r   Zsixr   r   r   	functoolsr   r   collectionsr	   r
   Zflaskr   r   r   r   Zflask.viewsr   Zflask_mongorestr   rS   rp   	constantsr   r   Zmarshmallow_apispecr   r   r   r   r=   r6   r   r   r   r   r   r   r   r   r   r   r   r   r   rb   rr   r  r   r   rQ   rO   r  objectr  r6  r;  rN  rG  rc   r   r   r#   r#   r#   r$   <module>   s   
 
h-
 


	

+
:
$
P
@1