Skip to content

Fix an issue where JSON schema extras weren't JSON encoded#7625

Merged
dmontagu merged 2 commits intomainfrom
dmontagu/fix-unencoded-json-schema
Sep 26, 2023
Merged

Fix an issue where JSON schema extras weren't JSON encoded#7625
dmontagu merged 2 commits intomainfrom
dmontagu/fix-unencoded-json-schema

Conversation

@dmontagu
Copy link
Copy Markdown
Contributor

Closes fastapi/fastapi#10321

As far as I can tell, in v1, we would json encode anything extra (which included the examples). So I think this is restoring intended behavior (and as far as I can imagine is objectively better behavior in all circumstances where it might affect things).

@Kludex for reference

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Sep 26, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: b6c62e3
Status: ✅  Deploy successful!
Preview URL: https://7508f175.pydantic-docs2.pages.dev
Branch Preview URL: https://dmontagu-fix-unencoded-json.pydantic-docs2.pages.dev

View logs

@dmontagu
Copy link
Copy Markdown
Contributor Author

Note this doesn't affect the result of a mutating json_schema_extra. To make that work would be a bit more complex because it makes in-place changes, so a straightforward call to to_jsonable_python won't work out of the box as that won't mutate the input. But it could be made to work, I'm just not sure it's worth the overhead it would add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes-fix Used for bugfixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pydantic 2 Regression: Openapi error when "examples" contains models

2 participants