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

fix(core): make JSON Schemas at packages/core/src/ruleset/meta valid #2788

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

jviotti
Copy link

@jviotti jviotti commented Feb 25, 2025

Plus add a GitHub Action that uses sourcemeta/jsonschema to perform some basic smoke tests to prevent regressions.

Fixes: #2787

@jviotti jviotti requested a review from a team as a code owner February 25, 2025 01:31
@jviotti
Copy link
Author

jviotti commented Feb 25, 2025

I tried to setup a basic GitHub Action to prevent regressions here, but as I sent the PR, I'm now realising you use CircleCI. Happy to revise the PR to just fix the schemas.

@jviotti jviotti changed the title fix(core): Make JSON Schemas at packages/core/src/ruleset/meta valid fix(core): make JSON Schemas at packages/core/src/ruleset/meta valid 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
Copy link
Author

jviotti commented Feb 25, 2025

Ah, looking at the CircleCI failures, you seem to be using AJV (https://ajv.js.org). That explains why the schemas were invalid. AJV, despite being quite popular, is one of the least compliant JSON Schema validators we are aware of, with significant deviations from the specification. See Bowtie, the official JSON Schema project that ranks implementations by compliance and the amount of failures we record for AJV across versions of JSON Schema: https://bowtie.report/#/implementations/js-ajv.

I also touched on AJV on my talk at the last JSON Schema Conference (see https://www.youtube.com/watch?v=wJ7bK22n3IU) and how it can lead you to inadvertently write invalid schemas.

Screenshot 2025-02-24 at 9 38 07 pm

@jeremyfiel
Copy link
Contributor

the reason you're seeing the failure for $id ... 2020-12 is because Ajv requires a different import from the base version. The default import is for draft-07

If you want to use 2020-12, you need to import ajv/dist/2020

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

Successfully merging this pull request may close these issues.

The schemas at packages/core/src/ruleset/meta are invalid
2 participants