Commit ee4ea07
committed
(GH-538) Define VS Code extended vocabulary and dialect
This change addresses the need for parsing, validating, and processing
the custom JSON Schema keywords that VS Code recognizes for use in the
DSC schemas and resource schemas.
This change:
- Defines every custom keyword that the VS Code language server for JSON
recognizes as custom keywords in the `jsonschema` crate so that we can
correctly validate schemas that use those keywords programmatically.
The implementation in `jsonschema` is primarily intended for custom
validation keywords. Every custom keyword that VS Code recognizes is
an annotation keyword. They don't affect validation for instances of
data. This implementation ensures that we can parse those keywords for
our own use and validate that our schema definitions correctly define
values for those keywords.
- Defines the VS Code vocabulary, which includes the keywords. This
enables us to define our own dialects which recognize the VS Code
keywords.
- Defines a VS Code dialect, which includes the Draft 2020-12
vocabularies and the VS Code vocabulary.
- Defines the `VSCodeKeyword` enum for easier selection of keywords,
given that you can't ergonomically or safely pass a _type_ in Rust
functions.
This replaces the previous `VSCODE_KEYWORDS` struct.
- Updates the `idiomaticize_externally_tagged_enum` transform function
to use the `VSCodeKeyword` enum now that `VSCODE_KEYWORDS` is removed.
- Defines extension methods for the `ValidationOptions` struct from the
`jsonschema` crate to make adding VS Code keywords, vocabulary, and
dialect simpler and more ergonomic, participating in the builder
pattern that `jsonschema` uses when creating a validator.
- Defines extension methods for the `Schema` struct from the `schemars`
crate to simplify working with VS COde keywords in schemas, such as
retrieving the value for a keyword or checking whether the schema
uses the VS Code dialect.
- Adds three new extension methods to the `SchemaUtilityExtensions`
trait:
- `get_bundled_schema_resource_ids`, which retrieves the value of
the `$id` keyword from entries in the `$defs` keyword, each of which
represents a bundled schema resource.
- `get_references`, which recursively retrieves the value for every
`$ref` keyword in the schema.
- `replace_references`, which recursively replaces the value of the
`$ref` keyword from a given value to a new one specified by the
caller.
- `reference_is_for_bundled_resource`, which indicates whether a given
value for a `$ref` keyword points to a bundled schema resource in
the `$defs` keyword for the schema.
This change lays the groundwork for incorporating the VS Code keywords
into the schemas generated from Rust code and for defining our own
vocabulary for DSC as needed.1 parent befe473 commit ee4ea07
File tree
51 files changed
+6226
-64
lines changed- lib/dsc-lib-jsonschema
- locales
- src
- tests/vscode
- keywords
- transforms
- vscode
- keywords
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
51 files changed
+6226
-64
lines changedSome generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 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 | + | |
| 167 | + | |
0 commit comments