Reputation: 343
The requests
library documentation contains instructions on how to POST a multipart encoded file. This allows one to have a POST request with both a json
and files
part. An example is provided in this Stack Overflow answer.
Is there a way to validate/process this sort of request using APIFlask?
Initially, I imagined this sort of approach might work:
@v1.post("/data")
@v1.input(dataSchema, location="json") # `dataSchema` describes the JSON part of the request
@v1.input({'file': File()}, location="files") # inline schema dict
def post_data(json_data, file_data):
...
However it's specifically stated in the APIFlask documentation that:
you can only declare one body location for your view function, one of:
json
,form
,files
,form_and_files
,json_or_form
.
If I understand things correctly, a single location also implies a single unified schema, whereas I would prefer to keep the JSON schema separate. Can this be achieved in APIFlask?
Upvotes: 0
Views: 41
Reputation: 153
Personally, I think that for such complex requirements, you can consider using Flask to implement it.(APIFlask just extends Flask and does not affect usage)
Upvotes: 0