| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
This is quiet a large change to move away from oneOf in the schema to if/then/else. It provides much better error reporting than oneOf which prints a generic: "is not valid under any of the given schemas" without any context as it doesn't know which oneOf is closest to the one you want. This means I can get rid of all of the custom error diagnosis in error_processor.py and rely on Jsonschema to produce a better error message. I've run out of time to complete this pull request but still to do:
|
Sorry, something went wrong.
|
So Mike tested and unfortunately pydantic-codegen doesn't support if / then / else. But it looks like this use of if then else is what is intended: (see json schema issue: json-schema-org/json-schema-spec#31). For pydantic we can downgrade the if then else block to the following form: {
"if": {"$ref": "condition" },
"then": {"$ref": "schema1"},
"else": {"$ref": "schema2"}
}
to: {
"anyOf": [
{ "allOf": [ {"$ref": "condition" }, {"$ref": "schema1"} ] },
{ "allOf": [ {"not": {"$ref": "condition" } }, {"$ref": "schema2"} ] }
]
}
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes #154