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
Allow support for exclusion/inclusion of none and unset fields in OpenAPI schema #5693
base: master
Are you sure you want to change the base?
Conversation
📝 Docs preview for commit bc42942 at: https://63829f79adf1a077f4910f7c--fastapi.netlify.app |
📝 Docs preview for commit 53c5b4c at: https://638365e8adf1a0751591140e--fastapi.netlify.app |
📝 Docs preview for commit b1f7581 at: https://6383987b8f98a10b42c6c25f--fastapi.netlify.app |
📝 Docs preview for commit 35320a8 at: https://639ce6c6a7c2ed05d88a98ed--fastapi.netlify.app |
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.
Full disclosure: I can't speak to the appropriateness of where the parameters are applied, etc.
However:
- Reproduced behavior in master before fix (missing fields in example with 'none' value).
- Verified intended behavior after PR applied (configurable parameter, 'none' value in example).
- Verified tests ran successfully.
- Verified openapi.json is valid using online validator.
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.
I always override this using a script I write and this is literally can be helpful, especially in the next release 🚀
Summary
This PR addresses the issue #5559. Currently, the OpenAPI schema returned by
get_openapi
excludes none fields by default, and there are no parameters to customize this. The fix allows user to specify the exclusion/inclusion of none or unset fields when initializingFastAPI()
.