Skip to content
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

Moving away from oneOf #155

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open

Moving away from oneOf #155

wants to merge 26 commits into from

Conversation

glenrobson
Copy link
Member

Fixes #154

@glenrobson glenrobson changed the title Adding AnnotationPageRef Moving away from oneOf Dec 10, 2022
@glenrobson
Copy link
Member Author

glenrobson commented Dec 10, 2022

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:

  • check if/then/else works with iiif-prezi3
  • move failing fixtures to /fixtures/3/broken/
  • check error messages of broken (both path + title and description)
  • remove redundant code in schemavalidator.py and the file error_processor.py
  • remove any other oneOfs in the schema
  • look at moving placeholder and accompanying canvas to being recursive
  • move schema tests into its own file
  • read all valid manifests and check

@glenrobson
Copy link
Member Author

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"} ] }
  ]
}

From json-schema-org/json-schema-spec#180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add AnnotationPage reference
1 participant