Skip to content

Don't lint default and examples siblings to $ref in Draft 7 and older#600

Open
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
evalon/blaze-dont-75e9fecf
Open

Don't lint default and examples siblings to $ref in Draft 7 and older#600
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
evalon/blaze-dont-75e9fecf

Conversation

@staging-devin-ai-integration
Copy link

Summary

In JSON Schema Draft 7 and older, implementations MUST ignore any keyword that is a sibling to $ref. The ValidDefault and ValidExamples lint rules were not respecting this — they would still validate and potentially remove default/examples when co-located with $ref in Draft 4, Draft 6, and Draft 7 schemas.

This adds an early-return in both ValidDefault::condition() and ValidExamples::condition(): if the schema object contains $ref and the active vocabulary is not 2019-09 or 2020-12, skip linting. For 2019-09 and 2020-12 (where $ref siblings are semantically meaningful), the existing removal behavior is preserved.

Fixes sourcemeta/jsonschema#425

Review & Testing Checklist for Human

  • Verify the negative vocabulary check (!2020-12 && !2019-09) is the correct way to identify Draft 7 and older, given that the function already gates on the five supported vocabularies earlier. Consider whether a positive check for draft-04/06/07 would be more defensive against future vocabulary additions.
  • Confirm the 2019-09 and 2020-12 "still removes" tests (tests 16/17 in both files) correctly demonstrate that invalid default/examples siblings to $ref are still erased in newer drafts.
  • Run make to verify all tests pass and no formatting drift remains.

Notes

In Draft 7 and older, JSON Schema implementations MUST ignore any keyword
that is a sibling to $ref. Updated ValidDefault and ValidExamples lint
rules to skip validation when default/examples are siblings to $ref in
Draft 4, Draft 6, and Draft 7 schemas.

For 2019-09 and 2020-12, the rules still correctly remove invalid
default/examples even when they are siblings to $ref.

Co-Authored-By: bot_apk <apk@cognition.ai>
@staging-devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

lint: default and $ref causing early process exit

0 participants