Code Monkey home page Code Monkey logo

Comments (4)

tiangolo avatar tiangolo commented on April 27, 2024 2

I guess this would be solved now by that new feature of the responses. So I'll close this issue now. But feel free to add more comments or create new issues.

from fastapi.

tiangolo avatar tiangolo commented on April 27, 2024

Thanks for the idea!

I think there are a couple of caveats to have in mind, but I'll check it with more attention. But first, let's solve #16, as that could include a solution for this too (at least an initial one).

from fastapi.

tiangolo avatar tiangolo commented on April 27, 2024

It's now possible to include responses in path operations: https://fastapi.tiangolo.com/tutorial/additional-responses/

You can also include responses that apply to several path operations: https://fastapi.tiangolo.com/tutorial/additional-responses/#combine-predefined-responses-and-custom-ones

And it's also supported in APIRouter, so you can add some responses to a whole sub-router in a single .include_router(): https://fastapi.tiangolo.com/tutorial/bigger-applications/#add-some-custom-tags-and-responses

Of course, this includes exceptions/error responses.

It's available in version 0.12.0.

from fastapi.

grbrlks avatar grbrlks commented on April 27, 2024

I think this would still be a nice feature as there are some limitations in regards of the responses feature.

You could also pass a custom response_class to specify the media type. With the responses feature I am not able to specify the media type of a specific response of the path operation, as far as I know.

@tiangolo please let me know if there is a way to do this or if you consider to implement this feature, keep up the good work!

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.