
    $gC                         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mZ d dlmZmZ d dlmZ  G d	 d
e          Z G d de          Z G d de          ZdS )    )dedent)BaseCommandCommandError)translation)import_string)GENERATOR_STATS)OpenApiJsonRendererOpenApiYamlRenderer)patched_settingsspectacular_settings)validate_schemac                       e Zd ZdS )SchemaGenerationErrorN__name__
__module____qualname__     o/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/drf_spectacular/management/commands/spectacular.pyr   r              Dr   r   c                       e Zd ZdS )SchemaValidationErrorNr   r   r   r   r   r      r   r   r   c                   6    e Zd Z ed          Zd Zd Zd ZdS )Commanda  
        Generate a spectacular OpenAPI3-compliant schema for your API.

        The warnings serve as a indicator for where your API could not be properly
        resolved. @extend_schema and @extend_schema_field are your friends.
        The spec should be valid in any case. If not, please open an issue
        on github: https://github.com/tfranzel/drf-spectacular/issues

        Remember to configure your APIs meta data like servers, version, url,
        documentation and so on in your SPECTACULAR_SETTINGS."
    c                 F   |                     ddddgdt                     |                     ddd t                     |                     d	d
d t                     |                     ddd t                     |                     dddd           |                     dddd           |                     ddd t                     |                     ddd t                     |                     dddd           |                     ddd t                     d S )Nz--formatformatopenapiopenapi-json)destchoicesdefaulttypez	--urlconfurlconf)r    r"   r#   z--generator-classgenerator_classz--filefilez--fail-on-warnfail_on_warnF
store_true)r    r"   actionz
--validatevalidatez--api-versionapi_versionz--langlangz--colorcolorz--custom-settingscustom_settings)add_argumentstr)selfparsers     r   add_argumentszCommand.add_arguments"   s?   JX	>?ZdmtwxxxKiCPPP/6GQU\_```H64cJJJ,>5YefffLz5Q]^^^O-TWXXXH64cJJJIGU<XXX/6GQU\_`````r   c                 v   |d         rt          |d                   }nt          j        }t          j                     |d         rt          j                      ||d         |d                   }|d         rt          |d                   }nd }t          |          5  |d         rJt          j        |d                   5  |	                    d d	          }d d d            n# 1 swxY w Y   n|	                    d d	          }d d d            n# 1 swxY w Y   t          j
                     |d
         rt          rt          d          |d         r2	 t          |           n!# t          $ r}t          |          d }~ww xY w|                     |d                   }|                    |i           }	|d         rFt#          |d         d          5 }
|
                    |	           d d d            d S # 1 swxY w Y   d S | j                            |	                                           d S )Nr%   r-   r$   r+   )r$   r+   r.   r,   T)requestpublicr'   z$Failing as requested due to warningsr*   r   )renderer_contextr&   wb)r   r   DEFAULT_GENERATOR_CLASSr   enable_trace_linenoenable_colorr   r   override
get_schemaemit_summaryr   r   	Exceptionr   get_rendererrenderopenwritestdoutdecode)r1   argsoptionsr%   	generatorr.   schemaerendereroutputfs              r   handlezCommand.handle.   sC   $% 	K+G4E,FGGOO2JO+---7 	+(***#OI&.
 
 
	
 $% 	#+G4E,FGGOO"Oo.. 	I 	Iv I )'&/:: M M&11$t1LLFM M M M M M M M M M M M M M M #--d4-HH	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	I 	$&&&>" 	P 	P'(NOOO: 	//'''' / / /+A.../ $$WX%677"==6? 	/gfot,,                                      Kfmmoo.....s`   !#DC(D(C,	,D/C,	0DDDE, ,
F
6FF
H  HHc                 @    t           t          d|         } |            S )N)r   r   )r
   r	   )r1   r   renderer_clss      r   r@   zCommand.get_renderer]   s,    */
 
  |~~r   N)r   r   r   r   helpr3   rN   r@   r   r   r   r   r      s[        6 
 
	 
	D
a 
a 
a-/ -/ -/^    r   r   N)textwrapr   django.core.management.baser   r   django.utilsr   django.utils.module_loadingr   drf_spectacular.drainager   drf_spectacular.renderersr	   r
   drf_spectacular.settingsr   r   drf_spectacular.validationr   r   r   r   r   r   r   <module>rZ      s9         A A A A A A A A $ $ $ $ $ $ 5 5 5 5 5 5 4 4 4 4 4 4 N N N N N N N N K K K K K K K K 6 6 6 6 6 6	 	 	 	 	L 	 	 		 	 	 	 	L 	 	 	M M M M Mk M M M M Mr   