Code Monkey home page Code Monkey logo

Comments (7)

tiangolo avatar tiangolo commented on April 29, 2024 3

It is now possible to add a parameter responses, in it you can declare additional OpenAPI responses or extend the main one, this includes other media types/content types, other status codes, headers, examples, description, etc: https://fastapi.tiangolo.com/tutorial/additional-responses/

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 0.12.0 🎉 🚀

from fastapi.

binary-signal avatar binary-signal commented on April 29, 2024 1

It is now possible to add a parameter responses, in it you can declare additional OpenAPI responses or extend the main one, this includes other media types/content types, other status codes, headers, examples, description, etc: https://fastapi.tiangolo.com/tutorial/additional-responses/

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 0.12.0 🎉 🚀

@tiangolo link provided in your answer give me an 404 error can you provide the correct link thanks !

from fastapi.

binary-signal avatar binary-signal commented on April 29, 2024 1

looks good now thanks @tiangolo

from fastapi.

tiangolo avatar tiangolo commented on April 29, 2024

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.

[...] though I've probably missed something because this is one of the best documented projects I've used.

That's great to hear! Thanks! ...although it is actually the case that it is not documented (yet) 🙈

from fastapi.

wshayes avatar wshayes commented on April 29, 2024

Thanks!

from fastapi.

jbkoh avatar jbkoh commented on April 29, 2024

@tiangolo Maybe the URL should be https://fastapi.tiangolo.com/advanced/additional-responses/ ?

from fastapi.

tiangolo avatar tiangolo commented on April 29, 2024

Yep, thanks for the link @jbkoh . I moved the docs when separating the tutorial in basic and advanced.

from fastapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.