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 #45

Closed khrvati closed 1 year ago

khrvati commented 1 year ago

This is a PR to solve #37

It adds a File class (a subclass of FileStorage) which can be used for type hints, either by itself or as list[File]

validate_request() awaits request.files and puts the FileStorage objects into the appropriate data field. If we're expecting a list of files, we call MultiDict.getlist() to get all the files that were provided.

_build_path() recognizes the presence of File and list[File] in the schema, and changes the encoding to multipart/form-data

Also modified the documentation to explain how to use this

pgjones commented 1 year ago

Thanks, I've taken a lot of inspiration from this, but chosen a slightly different direction in 766666d04a112e076a3b2945834e7f461d197a04