Replies: 7 comments
-
Documenting this in OpenAPI is something is currently not supported, although you can return anything you want if you use a Starlette response: https://www.starlette.io/responses/ But I'll have it in mind while checking how to document multiple response types.
That's great to hear! Thanks! ...although it is actually the case that it is not documented (yet) 🙈 |
Beta Was this translation helpful? Give feedback.
-
It is now possible to add a parameter The specific example with a different media type (the example is with an image) is here: https://fastapi.tiangolo.com/tutorial/additional-responses/#additional-media-types-for-the-main-response It is available in version |
Beta Was this translation helpful? Give feedback.
-
@tiangolo link provided in your answer give me an 404 error can you provide the correct link thanks ! |
Beta Was this translation helpful? Give feedback.
-
@tiangolo Maybe the URL should be https://fastapi.tiangolo.com/advanced/additional-responses/ ? |
Beta Was this translation helpful? Give feedback.
-
Yep, thanks for the link @jbkoh . I moved the docs when separating the tutorial in basic and advanced. |
Beta Was this translation helpful? Give feedback.
-
looks good now thanks @tiangolo |
Beta Was this translation helpful? Give feedback.
-
Description
How can I [...]?
I'm trying to figure out how to use one endpoint for multiple response content_types? I want to create an /export API endpoint and be able to dump (from memory) responses such as application/json, application/yaml or application/zip based on the content-type requested.
Everything I've seen so far is just for a single response type - though I've probably missed something because this is one of the best documented projects I've used.
Beta Was this translation helpful? Give feedback.
All reactions