(GH-538) Add VS Code keywords, vocabulary, and dialect to `dsc-lib-jsonschema`
PR Summary
This change:
-
Defines every custom keyword that the VS Code language server for JSON recognizes as custom keywords in the
jsonschemacrate so that we can correctly validate schemas that use those keywords programmatically.The implementation in
jsonschemais 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
VSCodeKeywordenum for easier selection of keywords, given that you can't ergonomically or safely pass a type in Rust functions.This replaces the previous
VSCODE_KEYWORDSstruct. -
Updates the
idiomaticize_externally_tagged_enumtransform function to use theVSCodeKeywordenum now thatVSCODE_KEYWORDSis removed. -
Defines extension methods for the
ValidationOptionsstruct from thejsonschemacrate to make adding VS Code keywords, vocabulary, and dialect simpler and more ergonomic, participating in the builder pattern thatjsonschemauses when creating a validator. -
Defines extension methods for the
Schemastruct from theschemarscrate 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
SchemaUtilityExtensionstrait:get_bundled_schema_resource_ids, which retrieves the value of the$idkeyword from entries in the$defskeyword, each of which represents a bundled schema resource.get_references, which recursively retrieves the value for every$refkeyword in the schema.replace_references, which recursively replaces the value of the$refkeyword 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$refkeyword points to a bundled schema resource in the$defskeyword for the schema.
PR Context
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 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.