-
Notifications
You must be signed in to change notification settings - Fork 290
Support draft-04 schemas #1065
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 draft-04 schemas #1065
Conversation
Adding the warning is much harder than I anticipated. We depend on vscode-json-languageservice and use some if its internal code. vscode-json-languageservice doesn't support reporting warnings on schemas until the next major version. A lot of the internals have changed, so by bumping vscode-json-languageservice, I prevent the extension from being able to compile. |
d4c0017
to
0400d2a
Compare
The primary motivation for doing this is to allow warnings to be reported on schemas. I would like to report warnings on schemas as a part of redhat-developer#1065. When updating the json language service, there were many API changes that I needed to adapt to, and some tests that I changed. Notably, I needed to copy a lot of the implementation of `JSONSchemaService` into our subclass of `JSONSchemaService`. `JSONSchemaService` turns all schema identifiers into URIs and escapes all `/` in the fragment, and does this in the private `normalizeId` method that we can't override Combined, these behaviours cause many tests to fail. Closes redhat-developer#1069 Signed-off-by: David Thompson <[email protected]>
IMO, it makes more sense to get this merged first. This PR fixes a real problem. That PR is risky at best; we are playing around with a lot of internals of the json-languageservice and I don't think I have a strong enough grasp on this code base to not have messed something up. |
0400d2a
to
de77c69
Compare
@Davidonium if you have some time, could you please let me know what you think of this PR? |
Sure thing, I will grab a look tomorrow |
de77c69
to
12ea8a5
Compare
@msivasubramaniaan if you have a time, could you also please take a look at this? |
Bump! :) |
@datho7561 please confirm that redhat-developer/vscode-yaml#1100 should work with this fix |
This helps to support the schema for openapi 3.0.0, among others, that use an older draft of JSON schema that has some type differences that make it incompatible with JSON schema draft 07. See redhat-developer#1006 , I think the root cause for the issues that PR caused is that we were trying to download and cache the metaschema from the "URL" instead of using the copy that's bundled with `ajv`. Fixes redhat-developer#780, Fixes redhat-developer#752 (and many, many duplicates we'll have to find and clean up) Signed-off-by: David Thompson <[email protected]>
12ea8a5
to
8a9f70a
Compare
@msivasubramaniaan I made sure that redhat-developer/vscode-yaml#1100 works with this fix, and added a test case for https://json-schema.org/draft-04/schema# |
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.
@datho7561 thanks for the fix. It works on both HTTP
and HTTPS
Amazing work from developers! Do you have a rough idea of the next release date? |
What does this PR do?
This helps to support the schema for openapi 3.0.0, among others, that use an older draft of JSON schema that has some type differences that make it incompatible with JSON schema draft 07.
See #1006 , the root cause for the issues that PR caused is that some schemas reference the metaschema using
https
, eg.https://json-schema.org/draft-07/schema#
, which is invalid according to the spec. This PR suppresses this error, because in practice many schemas usehttps
for the metaschema reference, and that shouldn't prevent validation of the YAML document.- [ ] TODO: Instead, we should provide a warning letting the user know about theI feel like we should do this in a separate PR, later, since it's complex (see #1065 (comment)).https
issue in the schema so they can fix the schema or file an issue to get the schema fixed.What issues does this PR fix or reference?
Fixes #780, Fixes #752
(and many, many duplicates we'll have to find and clean up)
Is it tested? How?
Unit test