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

Allow support for exclusion/inclusion of none and unset fields in OpenAPI schema #5693

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jaejaywoo
Copy link

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 initializing FastAPI().

@github-actions
Copy link
Contributor

📝 Docs preview for commit bc42942 at: https://63829f79adf1a077f4910f7c--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit 53c5b4c at: https://638365e8adf1a0751591140e--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit b1f7581 at: https://6383987b8f98a10b42c6c25f--fastapi.netlify.app

@github-actions
Copy link
Contributor

📝 Docs preview for commit 35320a8 at: https://639ce6c6a7c2ed05d88a98ed--fastapi.netlify.app

Copy link
Sponsor

@Ryandaydev Ryandaydev left a 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.

Copy link
Contributor

@yezz123 yezz123 left a 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 🚀

@tiangolo tiangolo added the feature New feature or request label Oct 2, 2023
@alejsdev alejsdev added p3 and removed investigate labels Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request p3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants