Fastapi: [BUG] Override successful response

Created on 7 Jun 2020  路  11Comments  路  Source: tiangolo/fastapi

Describe the bug

On the responses field in the route decorator we can't override the description of the successful response. Even on the tutorial we can see it: https://fastapi.tiangolo.com/advanced/additional-responses/

To Reproduce

image
image

Expected behavior

We should have "Item requested by ID" in the description field for the code 200.

answered bug

Most helpful comment

@tiangolo Side note: Thanks for including the version number that included the bug fix. As a busy, busy dev it makes my life much easier knowing immediately what version to bump to, so that was really appreciated.

All 11 comments

We can use response_description, but we can't override with responses so the BUG still remains.

Hey i would like to contribute and perhaps some mentorship. This would be my first contribution to open source

@fabrizzioalco that's great!

You should probably:

  • Make sure to read and follow the tutorial and get familiar with using the framework and how it works
  • You could help others here and in the Gitter chat, many questions just need a bit of guidance and help. And by helping others you would get a lot more expertise with FastAPI.
  • If you speak another language apart from English, you could help with the translations to your language, that's something that only a few can do (and I can't, as I don't speak all the languages :sweat_smile: ): https://fastapi.tiangolo.com/contributing/#translations

    • And as by doing that you would be reading the documentation, having to understand it, and re-writing it in your language, you would probably learn a lot of the concepts and how it all works.

  • If you want to contribute code to FastAPI itself, check the contributing guide: https://fastapi.tiangolo.com/contributing/

@tiangolo if there has not been any PRs yet, i have been thinking of looking into contributing to this issue. what do you think?

@rkbeatss I can say that there are no PRs solving it for now, I think you can safely work on it :)

Please, be my guest. I had some troubles so i can't work on this @rkbeatss

Later i would contribute on something else

Thanks for the report and for the discussion here everyone! :coffee:

And thanks @rkbeatss for the initial implementation! :cake:

This should be fixed in https://github.com/tiangolo/fastapi/pull/1577

Available in FastAPI version 0.58.0 :tada:

Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues.

Wow, this is fantastic - I literally just ran into this bug (was on 0.54) so I was really excited to see it fixed. I couldn't use response_model in one of my handlers because the response was large as raw data, and serializing it to pydantic classes increased response time by like 4x. Being able to skip runtime validation but still have documentation is just wonderful.

@tiangolo Side note: Thanks for including the version number that included the bug fix. As a busy, busy dev it makes my life much easier knowing immediately what version to bump to, so that was really appreciated.

Was this page helpful?
0 / 5 - 0 ratings