-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
When using "all_refs=True" to generate a jsonschema, validation fails because the top-level object has invalid reference url #126
Comments
Hi @gshank This is a very interesting issue!
I thought so at first too and went to look for confirmation which led me to this: So, it's legit to have "$ref" and "$defs" keywords in the root schema. But something was totally wrong here. After taking a close look at difference between v11.json and an example from the linked issue I figured out that problem was with "$". By mistake, we use prefix "$ref": "#/defs/WritableManifest" there should be this: "$ref": "#/$defs/WritableManifest" I can confirm that after passing correct json_schema_obj = build_json_schema(cls, all_refs=True, ref_prefix="#/$defs")
I will change the default |
Description
I have the conversion from our old jsonschema generation app (hologram) to mashumaro working okay without the "all_refs" parameter turned on, but that makes the generated jsonschema very large. When I turn on "all_refs", it generates a much smaller jsonschema, but validation fails because the top-level object is a ref.
What I Did
If you look at dbt-labs/dbt-core#8132, the schemas/dbt/manifest/v11.json file was generated from mashumaro (it's big and might not load in the browser). The previous generated file was schemas/dbt/manifest/v10.json, for comparison purposes.
When I modify core/dbt/dataclass_schemas.py, dbtClassMixin.json_schema to use "all_refs=True" to the "build_json_schema" call, the generated schema (added to the schemas directory by
scripts/collect-artifact-schema.py --path schemas --artifact manifest
) fails the schema tests (tests/functional/artifacts) with the error message: jsonschema.exceptions.RefResolutionError: Unresolvable JSON pointer: 'defs/WritableManifest'The WritableManifest is the top-level object that I am creating the jsonschema for, so my guess is that the base object cannot be a ref, but this is not my area of expertise. Let me know if I should try to create a test case.
The text was updated successfully, but these errors were encountered: