-
Notifications
You must be signed in to change notification settings - Fork 52
(GH-538) Add dsc-lib-jsonschema
crate
#1171
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
base: main
Are you sure you want to change the base?
(GH-538) Add dsc-lib-jsonschema
crate
#1171
Conversation
567daae
to
2d9b276
Compare
d3c21ef
to
09a7538
Compare
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
//! Unit tests for [`dsc-lib-jsonschema::transforms`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc examples are run as part of cargo test
so do we need this placeholder for unittests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not strictly required. The intent here is to add unit tests as they make sense, but these two transforms really only make sense to test at an integration level, which is why I left this file empty.
|
||
/// Defines an enum where each variant maps to a string value. This enum includes every | ||
/// supported documentation keyword for the enum and each variant. | ||
#[allow(dead_code)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably better to have this in a scope that is #[cfg(test)]
so it's conditionally compiled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of the code in lib/dsc-lib-jsonschema/tests
is #[cfg(test)]
scoped. This folder is only compiled for cargo's integration tests, but I also applied the attribute on every module declaration, e.g.
#[cfg(test)] mod string_variants;
lib/dsc-lib-jsonschema/Cargo.toml
Outdated
pretty_assertions = { workspace = true } | ||
|
||
[lints.clippy] | ||
pedantic ={ level = "deny" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a specific pedantic rule(s) you are suppressing?
pedantic ={ level = "deny" } | |
pedantic = { level = "deny" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is functionally hoisting the deny flag from the CLI to the configuration file. I was trying to get rust analyzer to flag pedantic lints for me without having to separately run clippy.
This change begins the schema canonicalization process by adding a new library crate to contain the helpers for defining canonical and enhanced schemas ergonomically. In this initial phase, the new crate defines: - The `VSCODE_KEYWORDS` constant, enumerating the keywords that VS Code's JSON language server recognizes. - The `idiomaticize_string_enum` transformer for munging the generated schemas for string enums with annotation keywords. - The `idiomaticize_externally_tagged_enum` transformer for munging the generated schemas for externally tagged enums to a more idiomatic and readable representation.
This change uses the new `idiomaticize_*` transformers from the `dsc-lib-jsonschema` crate in the `dsc-lib` crate to ensure that the generated schemas are idiomatic.
This change updates the i18n Pester tests to account for: - Usage of the `t!` macro when the translation key is defined on the next line. - Usage of the convenience `panic_t!` macro, which simplifies sending translated strings to the `panic!` macro. - Usage of the convenience `assert_t!` macro, which simplifies sending translated strings to the panic when an `assert!` macro fails. These use cases were required for the `dsc-lib-jsonschema` crate, which uses both `panic_t!` and `assert_t!` to raise translated panic messages when a transform is invalidly applied. While this change doesn't modify the behavior for any other crates, it does lay the groundwork for translating panic messages and assertions throughout the crates.
09a7538
to
393d6a2
Compare
PR Summary
This change begins the schema canonicalization process by adding a new library crate to contain the helpers for defining canonical and enhanced schemas ergonomically.
In this initial phase, the new crate defines:
VSCODE_KEYWORDS
constant, enumerating the keywords that VS Code's JSON language server recognizes.idiomaticize_string_enum
transformer for munging the generated schemas for string enums with annotation keywords.idiomaticize_externally_tagged_enum
transformer for munging the generated schemas for externally tagged enums to a more idiomatic and readable representation.This change uses the new
idiomaticize_*
transformers from thedsc-lib-jsonschema
crate in thedsc-lib
crate to ensure that the generated schemas are idiomatic.PR Context
dsc schema
command #538