miguelgrinberg / microblog-api

A modern (as of 2024) Flask API back end.
MIT License
365 stars 100 forks source link

Accepting images to api endpoint #17

Open dougclift opened 1 year ago

dougclift commented 1 year ago

I'm building an app where you'll be able to upload an image to the api which will then process the image. The api will reply with an accepted or error message.

I'm curious how I would add an image to the schemas so the documentation shows the api can accept images (.png/.jpg) to the endpoint?

Thanks.

miguelgrinberg commented 1 year ago

I have really not thought about it, because the goal of APIFairy is to handle JSON endpoints. But there is really no requirement that you use APIFairy decorators for every endpoint. You can manually edit the OpenAPI definition in a function decorated with the @process_apispec decorator. You should be able to use the @response decorator if your response to the file upload is JSON, and just manually edit the input so that OpenAPI knows it is a file.