#1112 - Support JSON Schema 2019-09 and 2020-12 by migrating to @hyperjump/json-schema
Support JSON Schema 2019-09 and 2020-12 by migrating to @hyperjump/json-schema
🎯 Overview
Fixes #1112 by replacing AJV with @hyperjump/json-schema to enable support for JSON Schema 2019-09 and 2020-12 specifications.
🔄 Key Changes
Dependency Migration
- ❌ Removed:
ajvandajv-draft-04(limited to draft-04/07) - ✅ Added:
@hyperjump/json-schema(supports all drafts including Draft 04, Draft 07, 2019-09, 2020-12)
Schema Service Updates
- Simplified validation logic in
yamlSchemaService.ts - Maintained full backward compatibility with existing draft-04/07 schemas
- Added native support for modern JSON Schema features:
-
$defskeyword -
unevaluatedProperties - Modern
exclusiveMinimum/exclusiveMaximum
-
Comprehensive Test Coverage
- 11 new test cases validating 2019-09 and 2020-12 support
- Test fixtures for both schema versions
- Verification of modern keyword handling
- Mixed version compatibility testing
@datho7561 FYI #1006
coverage: 83.964% (+0.008%) from 83.956% when pulling c3abaf3c6765fb290f2e6bfc27d8aa3ab543c3a1 on damioune123:feature/1112-support-json-schema-2019-and-2020 into 3821411ee8c92e5b7e5ca88f84ab443ae3b2791a on redhat-developer:main.
We need this !
Amazing, really need this ! When can this be merged?
I would love this as well! 👍
@msivasubramaniaan Hello dear Sir, Would it be possible to have a review on this Pull request as it is of high importance and for now, asserted public utility ? Thank you for your feedback and have a blessed day. Regards
@gorkem please please :-)
Nice job !
I'm planning finishing the release of 1.19.0 first (since we started the release process and never finished), but I intend to take a look at this after 1.19.0 is published.
Thank you @datho7561 !
Few notes for now, but I'll keep testing this PR tomorrow:
- I can't get either of
$dynamicRef(from 2019-09) or$recursiveRef(from 2020-12) working properly. I thought proper support for these features was the main selling point of swapping from AJV to hyperjump's JSON Schema validator. Can you confirm if this is expected to work? - Since this PR was opened, it seems like AJV has added support for 2020-12 (at least from what I can tell from the docs). It would be less risky to stick with AJV for validation instead of changing libraries, especially if it can support everything that hyperjump can. What are the advantages of hyperjump's implementation over AJV?
For this PR, keep in mind (I forgot this myself) that AJV (and now @hyperjump/json-schema in this pr) is only used to validate the referenced schema.
i.e. If you have this YAML file called ./product.yaml open:
# yaml-language-server: $schema=./product.schema.json
productId:
productId: 12
AJV/@hyperjump/json-schema will be used to validate ./product.schema.json, but not ./product.yaml
Hello everyone from the OpenAPI community 👋
We're currently leading an investigation as to why people are holding back migrating to OpenAPI 3.1/3.2, and the lack of support for JSON schema 2020-12 in a number of places seems to be one of the things holding people.
More context in this thread of the discussion
This pull request would be incredibly useful to move things forward, but it seems stalled? Would you mind sharing some more context? maybe we can help?
Thanks!
Cc @jdesrosiers the maintainer of hyperjump
Would you mind sharing some more context?
@baywet
This PR won't support validating YAML against a 2019-09 or 2020-12 JSON schema, which is probably what people want.
In order to properly validate the YAML against a 2019-09 or 2020-12 JSON schema, we will need to rewrite significant portions of this language server, since the code to validate the YAML against the JSON schema is in this repository and is not provided by an external dependency.
This PR supports validating the schema associated with a YAML file and reporting any errors in that schema. Once the wording of the README has been updated to reflect this and some proper test cases are added, I think this PR is good to merge. However, the original author of the PR hasn't responded to the review and I've been pretty busy with other stuff.
If folks think it's worth cleaning up this PR and getting it merged, let me know.
@datho7561 Thank you for the additional information!
Are there any plans/commitments to add support for 2020-12 in the language server from Red Hat/IBM at this stage? Is it safe to assumed that #856 is the correct issue to track that? For information, I had internal discussions with the team that owns the json language service, they are node code complete on support for 2020-12 yet, but getting there.
Are there any plans/commitments to add support for 2020-12 in the language server from Red Hat/IBM at this stage?
Not really, it's just me working on the project part time from Red Hat/IBM and it seems like a pretty major time commitment. I could review a PR if someone contributes it.
Is it safe to assumed that https://github.com/redhat-developer/yaml-language-server/issues/856 is the correct issue to track that?
Yes, that seems like a good place to track it.
Yes, that seems like a good place to track it.
Alright, I'll follow up there to avoid side-tracking this PR.
If @hyperjump/json-schema is useful for supporting 2020-12, let me know. I'd be happy to help if I can.
@jdesrosiers thanks for joining the conversation! one of the question that was pending (I didn't get the time to research it) in #856 is this: would we be able to get precise location information from the lib so we can report the errors back to vscode?