-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Ensure __get_pydantic_json_schema__
always gets the schema passed down from a wrapping handler
#5876
Conversation
with pytest.warns( | ||
DeprecationWarning, | ||
match=re.escape('The `schema_json` method is deprecated; use `model_json_schema` and json.dumps instead.'), | ||
): | ||
schema_json = Model.schema_json(indent=2) | ||
loaded_schema_json = json.loads(schema_json) |
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.
This just made no sense to have here
Deploying with Cloudflare Pages
|
please review |
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 think the arbitrary_types_allowed=True
error should be a little cleaner but overall this seems good to me.
Curious -- is this enough to get recursive type alias types JSON schema over the line, or does that stil need more?
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 think the arbitrary_types_allowed=True
error should be a little cleaner but overall this seems good to me.
Curious -- is this enough to get recursive type alias types JSON schema over the line, or does that stil need more?
Unfortunately, no. This still needs the changes in #5861 but since we should fix this anyway I didn't bother trying that branch on top of these changes, etc. |
pydantic/_internal/_dataclasses.py
Outdated
schema = get_core_schema(cls, partial(gen_schema.generate_schema, from_dunder_get_core_schema=False)) | ||
schema = get_core_schema( | ||
cls, | ||
CallbackGetCoreSchemaHandler( | ||
partial(gen_schema.generate_schema_for_type, from_dunder_get_core_schema=False), | ||
gen_schema.generate_schema, | ||
), | ||
) |
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.
We fixed this bug for BaseModel recently, just neglected to do so for dataclasses
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
7fd116d
to
01d8e91
Compare
please review |
Selected Reviewer: @dmontagu