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

fix: ensure extra fields present in jsonschema #284

Merged
merged 1 commit into from
Nov 10, 2023

Conversation

jsstevenson
Copy link
Contributor

@jsstevenson jsstevenson commented Nov 10, 2023

Not really sure why, but when RootModel classes are used as attributes in Pydantic models, the model_json_schema method seems to get very picky about how things like descriptions and examples are provided. Specifically, it wants them under the json_schema_extra param -- otherwise, they won't show up in the JSON schema produced by libraries like FastAPI. This PR makes this change (which coincidentally also silences a sort of annoying warning that starts appearing in more recent Pydantic v2 versions).

@jsstevenson jsstevenson marked this pull request as ready for review November 10, 2023 19:41
@jsstevenson jsstevenson requested review from a team as code owners November 10, 2023 19:41
Copy link
Contributor

@korikuzma korikuzma left a comment

Choose a reason for hiding this comment

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

Cool, I'll follow this for MetaKB

@jsstevenson jsstevenson merged commit 66ca5fd into 2-alpha Nov 10, 2023
8 checks passed
@jsstevenson jsstevenson deleted the pydantic-descriptions branch November 10, 2023 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants