Skip to content

Commit eb5c1c0

Browse files
authored
Merge pull request #989 from SteveL-MSFT/3.2-p3-schemars
Update dsc version to 3.2-preview.3 and schemars to 1.0
2 parents dcf9e51 + 11b1ecb commit eb5c1c0

File tree

24 files changed

+199
-162
lines changed

24 files changed

+199
-162
lines changed

archive/registry/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ clap = { version = "4.1", features = ["derive"] }
1919
crossterm = { version = "0.26" }
2020
ntreg = { path = "../ntreg" }
2121
ntstatuserror = { path = "../ntstatuserror" }
22-
schemars = { version = "0.8" }
22+
schemars = { version = "1.0" }
2323
serde = { version = "1.0", features = ["derive"] }
2424
serde_json = { version = "1.0", features = ["preserve_order"] }
2525

dsc/Cargo.lock

Lines changed: 13 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dsc/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dsc"
3-
version = "3.2.0-preview.2"
3+
version = "3.2.0-preview.3"
44
edition = "2021"
55

66
[profile.release]
@@ -23,12 +23,12 @@ jsonschema = { version = "0.30", default-features = false }
2323
path-absolutize = { version = "3.1" }
2424
regex = "1.11"
2525
rust-i18n = { version = "3.1" }
26-
schemars = { version = "0.8" }
26+
schemars = { version = "1.0" }
2727
serde = { version = "1.0", features = ["derive"] }
2828
serde_json = { version = "1.0", features = ["preserve_order"] }
2929
serde_yaml = { version = "0.9" }
3030
syntect = { version = "5.0", features = ["default-fancy"], default-features = false }
31-
sysinfo = { version = "0.35" }
31+
sysinfo = { version = "0.36" }
3232
thiserror = "2.0"
3333
tracing = { version = "0.1" }
3434
tracing-subscriber = { version = "0.3", features = ["ansi", "env-filter", "json"] }

dsc/src/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use dsc_lib::{
3535
use jsonschema::Validator;
3636
use path_absolutize::Absolutize;
3737
use rust_i18n::t;
38-
use schemars::{schema_for, schema::RootSchema};
38+
use schemars::{Schema, schema_for};
3939
use serde::Deserialize;
4040
use serde_json::Value;
4141
use std::collections::HashMap;
@@ -145,9 +145,9 @@ pub fn add_fields_to_json(json: &str, fields_to_add: &HashMap<String, String>) -
145145
///
146146
/// # Returns
147147
///
148-
/// * `RootSchema` - The schema
148+
/// * `Schema` - The schema
149149
#[must_use]
150-
pub fn get_schema(schema: SchemaType) -> RootSchema {
150+
pub fn get_schema(schema: SchemaType) -> Schema {
151151
match schema {
152152
SchemaType::GetResult => {
153153
schema_for!(GetResult)

dsc/tests/dsc_schema.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Describe 'config schema tests' {
77
$LASTEXITCODE | Should -Be 0
88
$schema | Should -Not -BeNullOrEmpty
99
$schema = $schema | ConvertFrom-Json
10-
$schema.'$schema' | Should -BeExactly 'http://json-schema.org/draft-07/schema#'
10+
$schema.'$schema' | Should -BeExactly 'https://json-schema.org/draft/2020-12/schema'
1111
}
1212

1313
It 'return dsc schema: <type>' -Skip:(!$IsWindows) -TestCases @(
@@ -26,14 +26,14 @@ Describe 'config schema tests' {
2626
$LASTEXITCODE | Should -Be 0
2727
$schema | Should -Not -BeNullOrEmpty
2828
$schema = $schema | ConvertFrom-Json
29-
$schema.'$schema' | Should -BeExactly 'http://json-schema.org/draft-07/schema#'
29+
$schema.'$schema' | Should -BeExactly 'https://json-schema.org/draft/2020-12/schema'
3030
}
3131

3232
It 'can accept the use of --output-format as a subcommand' {
3333
$schema = dsc resource schema -r Microsoft.DSC.Debug/Echo -o pretty-json
3434
$LASTEXITCODE | Should -Be 0
3535
$schema | Should -Not -BeNullOrEmpty
3636
$schema = $schema | ConvertFrom-Json
37-
$schema.'$schema' | Should -BeExactly 'http://json-schema.org/draft-07/schema#'
37+
$schema.'$schema' | Should -BeExactly 'https://json-schema.org/draft/2020-12/schema'
3838
}
3939
}

dsc_lib/Cargo.lock

Lines changed: 9 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dsc_lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ regex = "1.11"
2525
rt-format = "0.3"
2626
rust-i18n = { version = "3.1" }
2727
# reqwest = { version = "0.12.8", features = ["native-tls"], default-features = false }
28-
schemars = { version = "0.8", features = ["preserve_order"] }
28+
schemars = { version = "1.0", features = ["preserve_order"] }
2929
serde = { version = "1.0", features = ["derive"] }
3030
serde_json = { version = "1.0", features = ["preserve_order"] }
3131
serde_yaml = { version = "0.9" }

dsc_lib/src/configure/config_doc.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
use chrono::{DateTime, Local};
55
use rust_i18n::t;
6-
use schemars::JsonSchema;
6+
use schemars::{JsonSchema, json_schema};
77
use serde::{Deserialize, Serialize};
88
use serde_json::{Map, Value};
99
use std::collections::HashMap;
@@ -193,12 +193,11 @@ impl DscRepoSchema for Configuration {
193193
const SCHEMA_FOLDER_PATH: &'static str = "config";
194194
const SCHEMA_SHOULD_BUNDLE: bool = true;
195195

196-
fn schema_metadata() -> schemars::schema::Metadata {
197-
schemars::schema::Metadata {
198-
title: Some(t!("configure.config_doc.configurationDocumentSchemaTitle").into()),
199-
description: Some(t!("configure.config_doc.configurationDocumentSchemaDescription").into()),
200-
..Default::default()
201-
}
196+
fn schema_metadata() -> schemars::Schema {
197+
json_schema!({
198+
"title": t!("configure.config_doc.configurationDocumentSchemaTitle").to_string(),
199+
"description": t!("configure.config_doc.configurationDocumentSchemaDescription").to_string(),
200+
})
202201
}
203202

204203
fn validate_schema_uri(&self) -> Result<(), DscError> {

dsc_lib/src/dscresources/resource_manifest.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
use rust_i18n::t;
5-
use schemars::JsonSchema;
5+
use schemars::{Schema, JsonSchema, json_schema};
66
use semver::Version;
77
use serde::{Deserialize, Serialize};
88
use serde_json::Value;
@@ -240,12 +240,11 @@ impl DscRepoSchema for ResourceManifest {
240240
const SCHEMA_FOLDER_PATH: &'static str = "resource";
241241
const SCHEMA_SHOULD_BUNDLE: bool = true;
242242

243-
fn schema_metadata() -> schemars::schema::Metadata {
244-
schemars::schema::Metadata {
245-
title: Some(t!("dscresources.resource_manifest.resourceManifestSchemaTitle").into()),
246-
description: Some(t!("dscresources.resource_manifest.resourceManifestSchemaDescription").into()),
247-
..Default::default()
248-
}
243+
fn schema_metadata() -> Schema {
244+
json_schema!({
245+
"title": t!("dscresources.resource_manifest.resourceManifestSchemaTitle").to_string(),
246+
"description": t!("dscresources.resource_manifest.resourceManifestSchemaDescription").to_string(),
247+
})
249248
}
250249

251250
fn validate_schema_uri(&self) -> Result<(), DscError> {

dsc_lib/src/extensions/extension_manifest.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT License.
33

44
use rust_i18n::t;
5-
use schemars::JsonSchema;
5+
use schemars::{Schema, JsonSchema, json_schema};
66
use semver::Version;
77
use serde::{Deserialize, Serialize};
88
use serde_json::Value;
@@ -41,12 +41,11 @@ impl DscRepoSchema for ExtensionManifest {
4141
const SCHEMA_FOLDER_PATH: &'static str = "extension";
4242
const SCHEMA_SHOULD_BUNDLE: bool = true;
4343

44-
fn schema_metadata() -> schemars::schema::Metadata {
45-
schemars::schema::Metadata {
46-
title: Some(t!("extensions.extension_manifest.extensionManifestSchemaTitle").into()),
47-
description: Some(t!("extensions.extension_manifest.extensionManifestSchemaDescription").into()),
48-
..Default::default()
49-
}
44+
fn schema_metadata() -> Schema {
45+
json_schema!({
46+
"title": t!("extensions.extension_manifest.extensionManifestSchemaTitle").to_string(),
47+
"description": t!("extensions.extension_manifest.extensionManifestSchemaDescription").to_string(),
48+
})
5049
}
5150

5251
fn validate_schema_uri(&self) -> Result<(), DscError> {

0 commit comments

Comments
 (0)