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

Support Custom Meta-schemas #19

Closed
dszier opened this issue Jun 5, 2019 · 4 comments
Closed

Support Custom Meta-schemas #19

dszier opened this issue Jun 5, 2019 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@dszier
Copy link

dszier commented Jun 5, 2019

I ran into the same issue with custom keywords as #16, but attempted to fix it by creating my own meta-schema that defines the keywords we use. Following the example of the hyper meta-schema, and the spec, I created a new meta-schema that defined my custom keywords. It referenced it's own id as $schema and incorporated draft-07 of the core meta-schema. However, when I try to read the schema, even withSchemaValidation(false), I get Unsuppoted metaschema: "http://my.company.com/meta-schemas/draft-01/schema#".

My thinking would be that I should be able to read the meta-schema itself without having to do anything special, and then when reading schemas that make use of the meta-schema, read them withSchemaResolver(new MyMetaSchemaResolver()). However, my schema resolver doesn't even have a chance to resolve the meta-schema because it seems that the exception bubbles up before calling resolve().

Am I doing something wrong and custom meta-schemas are already supported? Will this be a feature that Justify supports?

I took a look under the hood at how Justify creates JsonSchema objects for the core meta-schemas, and while I think I can get past the exception and read the meta-schema as a JsonSchema, it doesn't look like the internal schema catalog was really meant to be extended by having custom meta-schemas injected into it.

@leadpony
Copy link
Owner

leadpony commented Jun 5, 2019

Hello @dszier. Thank you for contacting me.
Unfortunately the library does not support custom meta-schema. Justify internally contains the official meta-schemas for the JSON Schema specification Draft-04, -06 and -07. Using thsese internal meta-schemas, the library automatically validates all JSON schemas while reading them if withSchemaValidation is set to true . Also the value of $schema keyword is used to detect the version of the JSON Schema specification between 3 drafts.
The JsonSchemaResolver interface is for resolving external schemas referenced by $ref keywords and not for resolving meta-schemas.
If the feature of cutsom meta-schema is really needed, we must start from designing the concept and the API.

@leadpony leadpony self-assigned this Jun 5, 2019
@dszier
Copy link
Author

dszier commented Jun 6, 2019

I think it would be great if custom meta-schemas were supported. If so, I could turn on strict validation of schemas against my own meta-schema.

However, with #16 fixed and a new version released, my needs will be met.

Thanks for the response and for maintaining this great library :)

@leadpony
Copy link
Owner

Hello @dszier
I have released 0.17.0 and it solved the issue #16 partially. Please see my comment in #16.
Also the support of custom meta-schema will be added in future release. I believe it is not so difficult to implement it.
Thank you so much for your nice suggestion of enhancement.

@leadpony leadpony added the enhancement New feature or request label Jun 15, 2019
@leadpony
Copy link
Owner

The new release 1.0.0 is now available, which supports custom metaschema feature. Please refer to the changelog.

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

No branches or pull requests

2 participants