-
-
Notifications
You must be signed in to change notification settings - Fork 249
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
The schemas at packages/core/src/ruleset/meta
are invalid
#2787
Comments
I guess one option is to make the schemas valid Draft 7, but might actually be easier to upgrade them to JSON Schema 2020-12. |
jviotti
added a commit
to jviotti/spectral
that referenced
this issue
Feb 25, 2025
Plus add a GitHub Action that uses `sourcemeta/jsonschema` to perform some basic smoke tests to prevent regressions. Fixes: stoplightio#2787 Signed-off-by: Juan Cruz Viotti <[email protected]>
I sent a PR to do enough to make the schemas work as 2020-12 schemas: #2788 |
jviotti
added a commit
to jviotti/spectral
that referenced
this issue
Feb 25, 2025
Plus add a GitHub Action that uses `sourcemeta/jsonschema` to perform some basic smoke tests to prevent regressions. Fixes: stoplightio#2787 Signed-off-by: Juan Cruz Viotti <[email protected]>
jviotti
added a commit
to jviotti/spectral
that referenced
this issue
Feb 25, 2025
Plus add a GitHub Action that uses `sourcemeta/jsonschema` to perform some basic smoke tests to prevent regressions. Fixes: stoplightio#2787 Signed-off-by: Juan Cruz Viotti <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey there! JSON Schema TSC member here. I'm trying to ingest the JSON Schemas maintained in this repository in my public JSON Schema registry (https://schemas.sourcemeta.com) (see sourcemeta/registry#146). While trying to do so, I uncovered a few problems with the schemas:
Both https://github.com/stoplightio/spectral/blob/develop/packages/core/src/ruleset/meta/js-extensions.json and https://github.com/stoplightio/spectral/blob/develop/packages/core/src/ruleset/meta/json-extensions.json have the same
$id
Most schemas make use of
$anchor
, which is a keyword introduced in JSON Schema 2019-09, and invalid in Draft 7 (see https://www.learnjsonschema.com/2019-09/core/anchor/). In Draft 7,$id
was used for the same purpose. i.e."$anchor": "foo"
was"$id": "#foo"
Most schemas make use of
$defs
, which is also a keyword introduced in JSON Schema 2019-09, and not recognised in Draft 7 (see https://www.learnjsonschema.com/2019-09/core/defs/). While many implementations are a bit permissive and may consider$ref
targets as subschemas, you have schemas like https://github.com/stoplightio/spectral/blob/develop/packages/core/src/ruleset/meta/shared.json, which serve as containers for anchored schemas. Because those are within$defs
, the entire thing just gets ignored. You probably meantdefinitions
in all of themIt is an anti-pattern for top-level
$id
to be relative URIs. Many implementations won't gracefully handle that. It uncovered a bug on my implementation (good stress test after all!) which I'm fixing now, but might be worth just adopting absolute URIs or even URNs if you don't expect to expose these schemas over HTTP yourselvesMaybe there are more issues, but at least those ones seemed to be the obvious ones making my tooling choke.
If I may ask, are you testing or validating those schemas at all right now? Just curious if there is a specific implementation that is somehow allowing the current use of invalid keywords.
I also recommend taking a look at my JSON Schema CLI tool (https://github.com/sourcemeta/jsonschema). Many projects use it on CI/CD (we have an easy to use GitHub Action for it) to:
metaschema
command)lint
command)test
command)Could be useful to avoid issues in the future! Happy to assist in all of the above!
The text was updated successfully, but these errors were encountered: