-
-
Notifications
You must be signed in to change notification settings - Fork 781
✨ Add json_schema_extra and deprecate schema_extra
#1035
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
base: main
Are you sure you want to change the base?
Conversation
|
Any news about this PR? |
|
Any possibility of a merge @tiangolo ? I would also be interested in this support being added / long term. |
|
Please merge this. |
Field() supports json_schema_extra for Pydantic v2Field() supports json_schema_extra for Pydantic v2
|
can you merge this? |
Co-authored-by: Motov Yurii <[email protected]>
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
yes, I can handle it. Help me reopen it. Should I add test cases for it? |
This comment was marked as resolved.
This comment was marked as resolved.
📝 Docs previewLast commit 249ad47 at: https://5ef99040.sqlmodel.pages.dev |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Co-authored-by: Motov Yurii <[email protected]>
Co-authored-by: Motov Yurii <[email protected]>
Field() supports json_schema_extra for Pydantic v2json_schema_extra and pydantic_kwargs params to Field() and deprecate schema_extra
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@KimigaiiWuyi, I suggested my way of fixing this, please review:
|
json_schema_extra and pydantic_kwargs params to Field() and deprecate schema_extrajson_schema_extra and deprecate schema_extra
According to what this link mentions,
PydanticV1's Field class supported passing arbitrary keyword arguments to the JSON schema. In SQLModel counterpart, it was supported by passing schema_extra (see this).
PydanticV2 still supports passing extra things to the JSON schema but in a slightly different way. One has to pass a dictionary in the json_schema_extra argument (see this).
So I modified the Field's parameters to be compatible and consistent with the
Pydantic v2parameters, and for backward compatibility, I didn't remove theschema_extrafield, which is logically compatible with both theschema_extraandjson_schema_extrapasses, andschema_extrashould be deprecated at some point in the future. field at some point in the future, but for nowschema_extrashould be retained.This Pull Reqeust is easy and simple, and easy to verify.