Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set response model defaults at application and router levels #2187

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

frjonsen
Copy link

@frjonsen frjonsen commented Oct 17, 2020

This would allow for setting the default value of response_model_by_alias, response_model_exclude_unset, response_model_exclude_defaults and response_model_exclude_none at an application or at a router level, rather than on each individual endpoint

@codecov
Copy link

codecov bot commented Oct 17, 2020

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (0e920e6) 100.00% compared to head (b9a32fa) 100.00%.
Report is 2286 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2187   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          239       239           
  Lines         7079      7127   +48     
=========================================
+ Hits          7079      7127   +48     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions
Copy link
Contributor

📝 Docs preview for commit b9a32fa at: https://5f8ab622324f65680ffc34bc--fastapi.netlify.app

@frjonsen frjonsen marked this pull request as ready for review October 18, 2020 06:54
@philipbjorge
Copy link

philipbjorge commented Apr 14, 2021

@frjonsen @astraldawn --
This would be useful for our team as we're having to set this on every API route.

What needs to happen to get this PR reviewed/considered for main?

Thanks for all your hard work 🙇 !

@@ -563,8 +596,25 @@ def include_router(
)
if responses is None:
responses = {}

for route in router.routes:
if isinstance(route, APIRoute):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverse the condition and add the continue statement to the if statement to decrease the indentation level.

@dkatzan
Copy link

dkatzan commented Feb 21, 2023

@cikay @frjonsen
will be happy to see this PR merged, as my team as well need to set these flags in every API route
looks like this PR is also a bit outdated and has conflicts

will be happy to pick it up from here and open a new PR

@frjonsen
Copy link
Author

will be happy to pick it up from here and open a new PR

I have since moved on to different projects that don't use FastAPI, so feel free finish this yourself, if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request p4
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants