o
    㥵iR                     @  s   d dl mZ d dlmZmZ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 erHdd
lmZ dd
lmZ ddlmZ ddlmZ d ddZd!ddZ d"ddZ!dS )#    )annotations)TYPE_CHECKINGOptionalTypeUnion)cast)ContentType)	BaseModel)get_argsget_type_hints   )get_model_fieldsget_model_json_schema)safe_issubclass)Kui   )specification)
UploadFilemodelType[BaseModel]returnspec.Schemac                 C  s   t | }|d ttj|S )Ntitle)r   poptyping_castspecSchema)r   schema r   F/home/ubuntu/.local/lib/python3.10/site-packages/kui/openapi/schema.py_schema   s   
r    bodyType[BaseModel] | NoneapplicationASGIKui | WSGIKuiOptional[spec.RequestBody]c                   sl    d u rd S dd t t|jjjddd D }t  D ]}t|jt	r)dg}qd fdd|D d	S )
Nc                 S  s   g | ]}t |trt|qS r   )
isinstancer   str).0vr   r   r   
<listcomp>!   s    z'schema_request_body.<locals>.<listcomp>T)include_extrasr   zmultipart/form-datac                   s   i | ]	}|d t  iqS )r   )r    )r(   content_typer!   r   r   
<dictcomp>1   s    z'schema_request_body.<locals>.<dictcomp>)requiredcontent)
r
   r   factory_classhttpdatar   valuesr   
annotationr   )r!   r#   content_typesfieldr   r-   r   schema_request_body   s$   

r8   r0   #Union[Type[BaseModel], spec.Schema]c                 C  s   t | tr| S t| S )N)r&   dictr    )r0   r   r   r   schema_response7   s   
r;   N)r   r   r   r   )r!   r"   r#   r$   r   r%   )r0   r9   r   r   )"
__future__r   typingr   r   r   r   r   r   baize.datastructuresr   pydanticr	   typing_extensionsr
   r   pydantic_compatibler   r   utilsr   asgir   ASGIKuiwsgiWSGIKui r   r   typesr   r    r8   r;   r   r   r   r   <module>   s     

