3
>^                 @   sL   d dl mZ d dlmZ d dlmZmZmZ d dlm	Z	 G dd deZ
dS )    )BaseCommand)coreapi)CoreJSONRendererJSONOpenAPIRendererOpenAPIRenderer)SchemaGeneratorc               @   s(   e Zd ZdZdd Zdd Zdd ZdS )	Commandz,Generates configured API schema for project.c             C   sT   |j ddd td |j ddd td |j ddd td |j dd	d
ddgd
td d S )Nz--titletitle)destdefaulttypez--urlurlz--descriptiondescriptionz--formatformatopenapizopenapi-jsoncorejson)r
   choicesr   r   )add_argumentstr)selfparser r   `/tmp/pip-build-8app2_gc/djangorestframework/rest_framework/management/commands/generateschema.pyadd_arguments   s    zCommand.add_argumentsc             O   sj   t d k	stdt|d |d |d d}|jd dd}| j|d }|j|i d	}| jj|jd
 d S )Nzcoreapi must be installed.r   r	   r   )r   r	   r   T)requestpublicr   )Zrenderer_contextzutf-8)	r   AssertionErrorr   Z
get_schemaget_rendererrenderstdoutwritedecode)r   argsoptions	generatorZschemaZrendereroutputr   r   r   handle   s    zCommand.handlec             C   s   t ttd| }| S )N)r   r   zopenapi-json)r   r   r   )r   r   Zrenderer_clsr   r   r   r   "   s
    zCommand.get_rendererN)__name__
__module____qualname__helpr   r&   r   r   r   r   r   r   
   s   r   N)Zdjango.core.management.baser   Zrest_framework.compatr   Zrest_framework.renderersr   r   r   Z!rest_framework.schemas.generatorsr   r   r   r   r   r   <module>   s   