Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix "Schema Key" becoming an entry in the meditor
Pydantic 2.0's JSON schema export no longer specifies a `type` field for the `schemaKey` property, and leaves it undefined instead. This change makes it so an undefined type also delegates it as a "basic schema", meaning it will not be rendered as its own tab in the meditor.
- Loading branch information
b3db231
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.
thanks @mvandenburgh . @candleindark let's check if there is something we can do in the model for
schemaKey
to have a behavior as before. if it cannot, let's consider removing it as a basic schema during generation.b3db231
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.
@satra If my guess is correct, I think you want to have the
"type"
key and its corresponding value back for the JSON-schema for theschemaKey
field of each model. This is the change mentioned in 3v in the top post of dandi/dandi-schema#203. If that's is the case, I believe I can customize the JSON schema generation to match the JSON schema in pervious version.Be aware though, this is a customization, and we are getting away from the standard behavior of JSON schema generation of Pydantic V2.
b3db231
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.
@satra Please checkout PR dandi/dandi-schema#227. I think it addresses the problem.
b3db231
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.
@satra Values allowed to be in a
Literal
expression must be a basic type in JSON, and values of different basic types in JSON are expressed differently. So Reverting the behavior of theschemaKey
to havetype
field is not really needed if you can construe the type of the value from the expression of the value in JSON. In Python,json.dumps
does this as illustrated in the following example. If there is a parallel behavior in TypeScript, then dandi/dandi-schema#227 is not needed.b3db231
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.
then let's keep the new behavior and update the meditor to address it as @mvandenburgh has done.