Commit 24c3800
JSON Schema 2019-09 support (#308)
* JSON Schema 2019-09 support
- Add $vocabulary support for vocabulary-based keyword filtering
- Implement $recursiveRef and $recursiveAnchor resolution
- Add duration and uuid format validators
- Fix $ref resolution with embedded $id schemas
- Improve unevaluatedProperties handling with dependentSchemas
- Support scope isolation for $ref with sibling keywords
* recursiveAnchor should always be a bool
* Add vocabulary tracking and format assertion support for JSON Schema 2019-09
- Change Vocabularies type from Set to Map to track required/optional status
- Add isFormatAssertionEnabled for format-annotation vs format-assertion
- Handle $ref sibling keywords correctly per draft version
- Only recognize $anchor in draft-2019-09 and later schemas
- Fix dependencies keyword to only apply in draft-07 and earlier
- Fix missing property error location to use object offset
* fix: correct vocabulary and draft-based keyword gating for JSON Schema 2019-09+
- Gate dependentRequired, dependentSchemas, unevaluatedProperties,
unevaluatedItems, minContains, maxContains to 2019-09+
- Gate prefixItems to 2020-12+
- Gate dependencies to draft-07 and earlier
- Apply vocabulary filtering only for 2019-09+ schemas
- Make format annotation-only by default for 2019-09+ per spec
- Support enabling format assertion via $vocabulary
- Stop treating $id fragments as anchors in 2019-09+
- Fix relative $id resolution when reached via JSON pointer $ref
- Highlight full object range for required property errors
* JSONSchemaService: Prevent duplicate anchor errors and ensure correct anchor resolution in schemas
* JSONSchemaService: Enhance sibling scope isolation for referenced schemas with additional tests
* Fix Goto Definition for anchors/embedded schemas, fix relative $schema vocabulary resolution
Address PR review feedback for JSON Schema 2019-09 support:
- Fix Goto Definition (findLinks) to support plain-name anchor fragments
(#foo via $anchor or legacy $id), and embedded schema references by $id URI
- Fix vocabulary extraction for custom dialects referenced via relative
$schema URI (e.g. "./dialect.jsonc") by resolving against the schema's
base URI before fetching
- Extract repeated absolute URI scheme regex into hasSchemeRegex constant
- Add tests for: anchor/embedded Goto Definition, $ref siblings ignored
in draft-07, unevaluatedProperties/unevaluatedItems ignored in draft-07,
nested embedded schemas, and vocabulary disable with relative URI
* fix: honor 2019-09 format vocabulary assertion flag
Treat the JSON Schema draft 2019-09 format vocabulary value as the
assertion switch: true enables supported format validation errors, while
false keeps format annotation-only.
Update schema and vocabulary tests to cover both required and optional
2019-09 format vocabulary behavior.
* refactor: address review feedback on $ref merge internals and vocabulary table
Addresses reviewer feedback on the 2019-09 support PR:
- Introduce a `MergedJSONSchema` interface (extends `JSONSchema` with a
typed `$originalId`) to replace the untyped `_originalId` hidden
property used to preserve a referenced schema's `$id` after a `$ref`
merge. `$originalId` is still defined non-enumerable so it stays out of
`for..in` iteration and JSON serialization, but consumers no longer
need `<any>` casts.
- Hoist the `vocabularyKeywords` table in vocabularies.ts to module scope
so it is not rebuilt on every `isKeywordEnabled` call.
- Fix base-URI tracking so a schema's own `$id` rebases its subtree even
at the root of a traversal. The second resolution pass (recursing from
resolveExternalLink) previously inherited the external schema's URI as
its base, so nested `$id` values were resolved against the wrong base.
Re-deriving the base from the root's own `$id` corrects this.
- With base tracking fixed, stop mutating the cached source schema in
mergeRef: clone the section before rewriting an inner relative `$ref`
to an absolute URI, instead of rewriting it in place.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Keegan Caruso <keegancaruso@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Martin Aeschlimann <martinae@microsoft.com>1 parent 5d87d16 commit 24c3800
12 files changed
Lines changed: 3422 additions & 399 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
41 | 50 | | |
42 | 51 | | |
43 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
| 67 | + | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
36 | 45 | | |
37 | 46 | | |
38 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
39 | 70 | | |
40 | 71 | | |
41 | 72 | | |
| |||
66 | 97 | | |
67 | 98 | | |
68 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
69 | 167 | | |
70 | 168 | | |
71 | 169 | | |
| |||
0 commit comments