pgjones / quart-schema

Quart-Schema is a Quart extension that provides schema validation and auto-generated API documentation.
MIT License
76 stars 24 forks source link

Add support for request File types #37

Closed pgjones closed 1 year ago

pgjones commented 1 year ago

Maybe via an API like,

class WithFile(BaseModel):
    description: str
    files: list[File]

The presence of File should change the encoding type to multipart/fom-encoded and be filled with the await request.files data.

I don't think I need a DataSource change, as either url or multipart encoded are fine Form types.

The File class needs something like this, so that pydantic creates the correct schema.

@classmethod
    def __modify_schema__(cls, field_schema: Dict[str, Any]) -> None:
        field_schema.update({"type": "string", "format": "binary"})
pgjones commented 1 year ago

Changed my mind about the datasource, see 766666d04a112e076a3b2945834e7f461d197a04