-
Notifications
You must be signed in to change notification settings - Fork 129
JSON Schema 2019-09 support #308
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
Open
keegan-caruso
wants to merge
9
commits into
microsoft:main
Choose a base branch
from
keegan-caruso:users/keegancaruso/2019-09-schema
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3295226
JSON Schema 2019-09 support
ab8a346
recursiveAnchor should always be a bool
eb89383
Add vocabulary tracking and format assertion support for JSON Schema …
72d5ab6
fix: correct vocabulary and draft-based keyword gating for JSON Schem…
d6e8322
Merge remote-tracking branch 'upstream/main' into users/keegancaruso/…
e99e4a7
JSONSchemaService: Prevent duplicate anchor errors and ensure correct…
f822189
JSONSchemaService: Enhance sibling scope isolation for referenced sch…
5c8674a
Fix Goto Definition for anchors/embedded schemas, fix relative $schem…
38e8a2c
Merge remote-tracking branch 'upstream/main' into users/keegancaruso/…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| * Licensed under the MIT License. See License.txt in the project root for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| /** | ||
| * Checks if a keyword is enabled based on the active vocabularies. | ||
| * If no vocabulary constraints are present, all keywords are enabled. | ||
| * Core keywords are always enabled regardless of vocabulary settings. | ||
| * | ||
| * @param keyword The keyword to check (e.g., 'type', 'properties', '$ref') | ||
| * @param activeVocabularies Set of active vocabulary URIs, or undefined if no constraints | ||
| * @returns true if the keyword should be processed, false otherwise | ||
| */ | ||
| export function isKeywordEnabled( | ||
| keyword: string, | ||
| activeVocabularies?: Set<string> | ||
| ): boolean { | ||
| const vocabularyKeywords: { [uri: string]: string[] } = { | ||
| 'https://json-schema.org/draft/2019-09/vocab/core': [ | ||
| '$id', '$schema', '$ref', '$anchor', '$recursiveRef', | ||
| '$recursiveAnchor', '$defs', '$comment', '$vocabulary' | ||
| ], | ||
| 'https://json-schema.org/draft/2019-09/vocab/applicator': [ | ||
| 'prefixItems', 'items', 'contains', 'additionalProperties', | ||
| 'properties', 'patternProperties', 'dependentSchemas', | ||
| 'propertyNames', 'if', 'then', 'else', 'allOf', 'anyOf', 'oneOf', 'not' | ||
| ], | ||
| 'https://json-schema.org/draft/2019-09/vocab/validation': [ | ||
| 'type', 'enum', 'const', 'multipleOf', 'maximum', 'exclusiveMaximum', | ||
| 'minimum', 'exclusiveMinimum', 'maxLength', 'minLength', 'pattern', | ||
| 'maxItems', 'minItems', 'uniqueItems', 'maxContains', 'minContains', | ||
| 'maxProperties', 'minProperties', 'required', 'dependentRequired' | ||
| ], | ||
| 'https://json-schema.org/draft/2019-09/vocab/meta-data': [ | ||
| 'title', 'description', 'default', 'deprecated', | ||
| 'readOnly', 'writeOnly', 'examples' | ||
| ], | ||
| 'https://json-schema.org/draft/2019-09/vocab/format': [ | ||
| 'format' | ||
| ], | ||
| 'https://json-schema.org/draft/2019-09/vocab/content': [ | ||
| 'contentEncoding', 'contentMediaType', 'contentSchema' | ||
| ], | ||
| 'https://json-schema.org/draft/2020-12/vocab/core': [ | ||
| '$id', '$schema', '$ref', '$anchor', '$dynamicRef', | ||
| '$dynamicAnchor', '$defs', '$comment', '$vocabulary' | ||
| ], | ||
| 'https://json-schema.org/draft/2020-12/vocab/applicator': [ | ||
| 'prefixItems', 'items', 'contains', 'additionalProperties', | ||
| 'properties', 'patternProperties', 'dependentSchemas', | ||
| 'propertyNames', 'if', 'then', 'else', 'allOf', 'anyOf', 'oneOf', 'not' | ||
| ], | ||
| 'https://json-schema.org/draft/2020-12/vocab/unevaluated': [ | ||
| 'unevaluatedItems', 'unevaluatedProperties' | ||
| ], | ||
| 'https://json-schema.org/draft/2020-12/vocab/validation': [ | ||
| 'type', 'enum', 'const', 'multipleOf', 'maximum', 'exclusiveMaximum', | ||
| 'minimum', 'exclusiveMinimum', 'maxLength', 'minLength', 'pattern', | ||
| 'maxItems', 'minItems', 'uniqueItems', 'maxContains', 'minContains', | ||
| 'maxProperties', 'minProperties', 'required', 'dependentRequired' | ||
| ], | ||
| 'https://json-schema.org/draft/2020-12/vocab/meta-data': [ | ||
| 'title', 'description', 'default', 'deprecated', | ||
| 'readOnly', 'writeOnly', 'examples' | ||
| ], | ||
| 'https://json-schema.org/draft/2020-12/vocab/format-annotation': [ | ||
| 'format' | ||
| ], | ||
| 'https://json-schema.org/draft/2020-12/vocab/format-assertion': [ | ||
| 'format' | ||
| ], | ||
| 'https://json-schema.org/draft/2020-12/vocab/content': [ | ||
| 'contentEncoding', 'contentMediaType', 'contentSchema' | ||
| ] | ||
| }; | ||
|
|
||
|
|
||
| // If no vocabulary constraints, treat all keywords as enabled | ||
| if (!activeVocabularies) { | ||
| return true; | ||
| } | ||
|
|
||
| // Check if this keyword belongs to any active vocabulary | ||
| for (const [vocabUri, keywords] of Object.entries(vocabularyKeywords)) { | ||
| if (keywords.includes(keyword) && activeVocabularies.has(vocabUri)) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| // Core keywords are always enabled per JSON Schema spec. | ||
| // Check both 2019-09 and 2020-12 core vocabularies. | ||
| const core201909 = vocabularyKeywords['https://json-schema.org/draft/2019-09/vocab/core']; | ||
| const core202012 = vocabularyKeywords['https://json-schema.org/draft/2020-12/vocab/core']; | ||
|
|
||
| if (core201909.includes(keyword) || core202012.includes(keyword)) { | ||
| return true; | ||
| } | ||
|
|
||
| // Keyword not found in any vocabulary - disable it | ||
| return false; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.