Skip to content

Conversation

@michaeltlombardi
Copy link
Collaborator

@michaeltlombardi michaeltlombardi commented Nov 19, 2025

PR Summary

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.

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.

@michaeltlombardi michaeltlombardi changed the title Gh 538/main/vscode keywords (GH-538) Add VS Code keywords, vocabulary, and dialect to dsc-lib-jsonschema Nov 19, 2025
@michaeltlombardi michaeltlombardi force-pushed the gh-538/main/vscode_keywords branch 5 times, most recently from b2cb10f to de60313 Compare November 24, 2025 19:21
Copilot finished reviewing on behalf of michaeltlombardi November 24, 2025 19:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds comprehensive support for VS Code's custom JSON Schema keywords, vocabulary, and dialect to the dsc-lib-jsonschema crate. The implementation enables programmatic validation and processing of schemas that use VS Code's extended keywords for enhancing the JSON authoring experience.

Key Changes:

  • Implements 14 VS Code annotation keywords (e.g., markdownDescription, defaultSnippets, enumDescriptions) with full validation support
  • Defines VS Code vocabulary and dialect meta-schemas for use in schema validation
  • Adds extension methods for Schema and ValidationOptions to simplify working with VS Code keywords
  • Extends schema utility functions with methods for handling schema references and bundled resources

Reviewed changes

Copilot reviewed 53 out of 54 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lib/dsc-lib-jsonschema/src/vscode/keywords/*.rs Individual keyword implementations with validation logic
lib/dsc-lib-jsonschema/src/vscode/vocabulary.rs VS Code vocabulary schema definition with static lazy initialization
lib/dsc-lib-jsonschema/src/vscode/dialect.rs VS Code dialect meta schema combining Draft 2020-12 and VS Code vocabulary
lib/dsc-lib-jsonschema/src/vscode/schema_extensions.rs Extension methods for retrieving VS Code keyword values from schemas
lib/dsc-lib-jsonschema/src/vscode/validation_options_extensions.rs Extension methods for registering VS Code keywords with validators
lib/dsc-lib-jsonschema/src/schema_utility_extensions.rs New utility methods for reference handling and bundled resource management
lib/dsc-lib-jsonschema/locales/*.{toml,yaml} Internationalized strings for keyword error messages and documentation
lib/dsc-lib-jsonschema/src/tests/vscode/**/*.rs Comprehensive test coverage for all new functionality
lib/dsc-lib/src/schemas/mod.rs Added documentation cross-references for schema form variants
build.helpers.psm1 Enhanced i18n testing infrastructure with YAML support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

This comment was marked as outdated.

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.
Prior to this change, the i18n tests used simple string matching to search for translation keys in the `en-us.toml` file and the project Rust code. This change defines a new `DscProjectRustTranslationInfo` class and `Get-TranslationKey` function in the `build.helpers` module. This change reimplements the i18n tests to use the new class and function for retrieving and analyzing translation strings for Rust projects, building in support for both TOML and YAML translation files. This is required to support the translation strings for JSON Schema annotations, which are lengthy. It enables us to keep the translations for messages in the code in the `en-us.toml` file and all schema-related translation strings in separate YAML files, where the hierarchy and multi-line strings fit more naturally. This change ensures that we can continue to accurately test our translation strings, checking: - That each project with a `locales` folder defines and uses at least one translation string. - That no translation keys are defined more than once across all translation files. - That every defined translation key is used in the Rust code. - That every translation key the Rust code references is defined in a translation file for `en-us`.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 53 out of 54 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@michaeltlombardi michaeltlombardi marked this pull request as ready for review November 24, 2025 20:14
}
#endregion Documenting project functions

#region Rust i18n type definitions and functions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere outside of the i18n tests? If not, would prefer to keep that code together in the test ps1 rather than creating a dependency on the helper module for that test

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put it here for easier access to checking translations during normal development workflow, since the i18n tests are in the dsc project - when working locally I was testing against the dsc-lib-jsonschema and dsc-lib crates independently.

Happy to move it though if that's preferable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference would be to move it since someone reading this in the future wouldn't be aware of the separation of the code. If it was used across multiple scripts, then it would make more sense to me to have it centralized here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants