-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
📝 Docs preview for commit b9a32fa at: https://5f8ab622324f65680ffc34bc--fastapi.netlify.app |
@frjonsen @astraldawn -- 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): |
There was a problem hiding this comment.
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.
I have since moved on to different projects that don't use FastAPI, so feel free finish this yourself, if you want. |
This would allow for setting the default value of
response_model_by_alias
,response_model_exclude_unset
,response_model_exclude_defaults
andresponse_model_exclude_none
at an application or at a router level, rather than on each individual endpoint