From 208ae9257f7f251fa1e9ee657c275d660e91d15c Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 29 Nov 2023 16:10:37 -0800 Subject: [PATCH 1/6] Update deps. --- CHANGELOG.md | 6 ++++++ Cargo.lock | 32 ++++++++++++++++---------------- Cargo.toml | 4 ++-- crates/config/Cargo.toml | 2 +- crates/macros/Cargo.toml | 2 +- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fc4e791..4dd960fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 0.12.9 + +#### ⚙️ Internal + +- Updated dependencies. + ## 0.12.8 #### ⚙️ Internal diff --git a/Cargo.lock b/Cargo.lock index 0b13cf2d..b82b8937 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1084,9 +1084,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" dependencies = [ "percent-encoding", ] @@ -1209,9 +1209,9 @@ dependencies = [ [[package]] name = "garde" -version = "0.16.2" +version = "0.16.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93476a1d00b9a3a72c886af12323f9f2ec59b5cf5260519306f77b062f49a06c" +checksum = "3f0bde634ca1248cfcd67a29f7b3798997d328406020f5e19b502b0a0d5e8cae" dependencies = [ "compact_str", "garde_derive", @@ -1491,9 +1491,9 @@ checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" +checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -2028,9 +2028,9 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "percent-encoding" -version = "2.3.0" +version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project-lite" @@ -2140,9 +2140,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.69" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] @@ -2697,9 +2697,9 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" dependencies = [ "serde_derive", ] @@ -2716,9 +2716,9 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.192" +version = "1.0.193" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" dependencies = [ "proc-macro2", "quote", @@ -3525,9 +3525,9 @@ dependencies = [ [[package]] name = "url" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "143b538f18257fac9cad154828a57c6bf5157e1aa604d4816b5995bf6de87ae5" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ "form_urlencoded", "idna", diff --git a/Cargo.toml b/Cargo.toml index d252a031..cfb49fce 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ regex = "1.10.2" relative-path = "1.9.0" rust_decimal = "1.33.1" semver = "1.0.20" -serde = { version = "1.0.192", features = ["derive"] } -url = "2.4.1" +serde = { version = "1.0.193", features = ["derive"] } +url = "2.5.0" version_spec = "0.1.5" warpgate = "0.5.14" diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index b61a59c3..3bda4c8e 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -23,7 +23,7 @@ thiserror = "1.0.50" tracing = "0.1.40" # config -garde = { version = "0.16.2", default-features = false, optional = true, features = [ +garde = { version = "0.16.3", default-features = false, optional = true, features = [ "regex", ] } serde = { workspace = true, optional = true } diff --git a/crates/macros/Cargo.toml b/crates/macros/Cargo.toml index 4ad3c48c..1ee11eb9 100644 --- a/crates/macros/Cargo.toml +++ b/crates/macros/Cargo.toml @@ -15,7 +15,7 @@ proc-macro = true [dependencies] convert_case = "0.6.0" darling = "0.20.3" -proc-macro2 = "1.0.69" +proc-macro2 = "1.0.70" quote = "1.0.33" syn = { version = "2.0.39", features = ["full"] } From b89a031325c2ec35c16b0b943c48bc52fcbe0d2b Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 29 Nov 2023 16:14:18 -0800 Subject: [PATCH 2/6] Add flatten. --- CHANGELOG.md | 4 ++++ crates/config/tests/macros_test.rs | 2 ++ crates/macros/src/common/field.rs | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dd960fa..2b89b595 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## 0.12.9 +#### 🚀 Updates + +- Added serde `flatten` support. + #### ⚙️ Internal - Updated dependencies. diff --git a/crates/config/tests/macros_test.rs b/crates/config/tests/macros_test.rs index f95cc298..58dfa51d 100644 --- a/crates/config/tests/macros_test.rs +++ b/crates/config/tests/macros_test.rs @@ -39,6 +39,8 @@ pub struct ValueTypes { s3_value: String, #[setting(nested, exclude)] other: OptionalValues, + #[setting(flatten)] + rest: HashMap, } #[derive(Config)] diff --git a/crates/macros/src/common/field.rs b/crates/macros/src/common/field.rs index 5372fd92..88bbaeba 100644 --- a/crates/macros/src/common/field.rs +++ b/crates/macros/src/common/field.rs @@ -12,6 +12,7 @@ use syn::{Attribute, Expr, ExprPath, Field as NativeField, Lit, Type}; #[darling(default, allow_unknown_fields, attributes(serde))] pub struct FieldSerdeArgs { pub alias: Option, + pub flatten: bool, pub rename: Option, pub skip: bool, } @@ -33,6 +34,7 @@ pub struct FieldArgs { pub validate: Option, // serde + pub flatten: bool, pub rename: Option, pub skip: bool, } @@ -112,6 +114,10 @@ impl<'l> Field<'l> { pub fn get_serde_meta(&self) -> Option { let mut meta = vec![]; + if self.args.flatten || self.serde_args.flatten { + meta.push(quote! { flatten }); + } + if let Some(rename) = &self.args.rename { meta.push(quote! { rename = #rename }); } else if let Some(rename) = &self.serde_args.rename { From 7d1707294365aa8d39cc5f27985e635f8c37645b Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 29 Nov 2023 16:29:11 -0800 Subject: [PATCH 3/6] Add serde json. --- CHANGELOG.md | 1 + Cargo.lock | 1 + Cargo.toml | 1 + README.md | 1 + crates/config/Cargo.toml | 4 ++- crates/config/tests/generator_test.rs | 1 + ...generator_test__json_schema__defaults.snap | 4 +++ ...nerator_test__typescript__const_enums.snap | 1 + .../generator_test__typescript__defaults.snap | 1 + .../generator_test__typescript__enums.snap | 1 + ...erator_test__typescript__exclude_refs.snap | 1 + ...ator_test__typescript__external_types.snap | 1 + .../generator_test__typescript__no_refs.snap | 1 + ...ator_test__typescript__object_aliases.snap | 1 + ...nerator_test__typescript__value_enums.snap | 1 + .../macros_test__generates_json_schema.snap | 26 +++++++++++++++ .../macros_test__generates_typescript-2.snap | 2 ++ .../macros_test__generates_typescript.snap | 2 ++ crates/test-app/Cargo.toml | 2 +- crates/types/Cargo.toml | 5 ++- crates/types/src/externals.rs | 32 ++++++++++++++++++- 21 files changed, 86 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b89b595..06b34792 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ #### 🚀 Updates - Added serde `flatten` support. +- Added `type_serde_json` feature, that implements schematic types for serde values. #### ⚙️ Internal diff --git a/Cargo.lock b/Cargo.lock index b82b8937..18832e37 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2636,6 +2636,7 @@ dependencies = [ "rust_decimal", "schematic_types", "semver", + "serde_json", "url", "version_spec", "warpgate", diff --git a/Cargo.toml b/Cargo.toml index cfb49fce..0e691aec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,6 +10,7 @@ relative-path = "1.9.0" rust_decimal = "1.33.1" semver = "1.0.20" serde = { version = "1.0.193", features = ["derive"] } +serde_json = "1.0.108" url = "2.5.0" version_spec = "0.1.5" warpgate = "0.5.14" diff --git a/README.md b/README.md index 2e909d3b..7b35dae9 100644 --- a/README.md +++ b/README.md @@ -693,6 +693,7 @@ The following Cargo features are available: - `type_relative_path` - Implements schematic for the `relative-path` crate. - `type_rust_decimal` - Implements schematic for the `rust_decimal` crate. - `type_semver` - Implements schematic for the `semver` crate. +- `type_serde_json` - Implements schematic for the `serde_json` crate. - `type_url` - Implements schematic for the `url` crate. - `type_version_spec` - Implements schematic for the `version_spec` crate. - `type_warpgate` - Implements schematic for the `warpgate` crate. diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 3bda4c8e..5a54e411 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -34,7 +34,7 @@ starbase_styles = { version = "0.1.16", optional = true } indexmap = { version = "2.1.0", optional = true } # json -serde_json = { version = "1.0.108", optional = true } +serde_json = { workspace = true, optional = true } # json schema schemars = { version = "0.8.16", optional = true, default-features = false } @@ -72,6 +72,7 @@ type_regex = ["schematic_types/regex"] type_relative_path = ["schematic_types/relative_path"] type_rust_decimal = ["schematic_types/rust_decimal"] type_semver = ["schematic_types/semver"] +type_serde_json = ["schematic_types/serde_json"] type_url = ["schematic_types/url"] type_version_spec = ["schematic_types/version_spec"] type_warpgate = ["schematic_types/warpgate"] @@ -92,6 +93,7 @@ schematic = { path = ".", features = [ "type_relative_path", "type_rust_decimal", "type_semver", + "type_serde_json", "type_url", "type_version_spec", "type_warpgate", diff --git a/crates/config/tests/generator_test.rs b/crates/config/tests/generator_test.rs index 59411639..652a78aa 100644 --- a/crates/config/tests/generator_test.rs +++ b/crates/config/tests/generator_test.rs @@ -52,6 +52,7 @@ struct GenConfig { spec_unresolved: version_spec::UnresolvedVersionSpec, id: warpgate::Id, locator: Option, + json_value: serde_json::Value, } fn create_generator() -> SchemaGenerator { diff --git a/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap b/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap index fc7894eb..109efe15 100644 --- a/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap +++ b/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap @@ -15,6 +15,7 @@ expression: "fs::read_to_string(file).unwrap()" "float32", "float64", "id", + "jsonValue", "locator", "map", "nested", @@ -62,6 +63,9 @@ expression: "fs::read_to_string(file).unwrap()" "id": { "type": "string" }, + "jsonValue": { + "type": "null" + }, "locator": { "anyOf": [ { diff --git a/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap b/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap index c0cce3c3..283fa579 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap @@ -27,6 +27,7 @@ export interface GenConfig { float32: number; float64: number; id: string; + jsonValue: unknown; locator: string | null; map: Record; nested: AnotherConfig; diff --git a/crates/config/tests/snapshots/generator_test__typescript__defaults.snap b/crates/config/tests/snapshots/generator_test__typescript__defaults.snap index c86d734d..4236f236 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__defaults.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__defaults.snap @@ -23,6 +23,7 @@ export interface GenConfig { float32: number; float64: number; id: string; + jsonValue: unknown; locator: string | null; map: Record; nested: AnotherConfig; diff --git a/crates/config/tests/snapshots/generator_test__typescript__enums.snap b/crates/config/tests/snapshots/generator_test__typescript__enums.snap index 7f294fd5..946ffdd3 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__enums.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__enums.snap @@ -27,6 +27,7 @@ export interface GenConfig { float32: number; float64: number; id: string; + jsonValue: unknown; locator: string | null; map: Record; nested: AnotherConfig; diff --git a/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap b/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap index b92017a8..7406b668 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap @@ -21,6 +21,7 @@ export interface GenConfig { float32: number; float64: number; id: string; + jsonValue: unknown; locator: string | null; map: Record; nested: AnotherConfig; diff --git a/crates/config/tests/snapshots/generator_test__typescript__external_types.snap b/crates/config/tests/snapshots/generator_test__typescript__external_types.snap index a2db1f88..75cd344e 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__external_types.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__external_types.snap @@ -25,6 +25,7 @@ export interface GenConfig { float32: number; float64: number; id: string; + jsonValue: unknown; locator: string | null; map: Record; nested: AnotherConfig; diff --git a/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap b/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap index 0288d3f7..1f81d7e3 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap @@ -23,6 +23,7 @@ export interface GenConfig { float32: number; float64: number; id: string; + jsonValue: unknown; locator: string | null; map: Record; nested: { diff --git a/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap b/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap index 2d645a80..5fb74c9b 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap @@ -23,6 +23,7 @@ export type GenConfig = { float32: number, float64: number, id: string, + jsonValue: unknown, locator: string | null, map: Record, nested: AnotherConfig, diff --git a/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap b/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap index b0d57e74..34b946d9 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap @@ -27,6 +27,7 @@ export interface GenConfig { float32: number; float64: number; id: string; + jsonValue: unknown; locator: string | null; map: Record; nested: AnotherConfig; diff --git a/crates/config/tests/snapshots/macros_test__generates_json_schema.snap b/crates/config/tests/snapshots/macros_test__generates_json_schema.snap index d3b6ded6..4b044094 100644 --- a/crates/config/tests/snapshots/macros_test__generates_json_schema.snap +++ b/crates/config/tests/snapshots/macros_test__generates_json_schema.snap @@ -691,6 +691,22 @@ expression: "std::fs::read_to_string(file).unwrap()" } ] }, + "rest": { + "anyOf": [ + { + "type": "object", + "additionalProperties": { + "type": "null" + }, + "propertyNames": { + "type": "string" + } + }, + { + "type": "null" + } + ] + }, "s3_value": { "anyOf": [ { @@ -822,6 +838,7 @@ expression: "std::fs::read_to_string(file).unwrap()" "enums", "map", "number", + "rest", "s3_value", "string", "vector" @@ -849,6 +866,15 @@ expression: "std::fs::read_to_string(file).unwrap()" "number": { "type": "number" }, + "rest": { + "type": "object", + "additionalProperties": { + "type": "null" + }, + "propertyNames": { + "type": "string" + } + }, "s3_value": { "type": "string" }, diff --git a/crates/config/tests/snapshots/macros_test__generates_typescript-2.snap b/crates/config/tests/snapshots/macros_test__generates_typescript-2.snap index 835f327a..d7db9251 100644 --- a/crates/config/tests/snapshots/macros_test__generates_typescript-2.snap +++ b/crates/config/tests/snapshots/macros_test__generates_typescript-2.snap @@ -43,6 +43,7 @@ export type ValueTypes = { enums: SomeEnum, map: Record, number: number, + rest: Record, s3_value: string, string: string, vector: string[], @@ -174,6 +175,7 @@ export type PartialValueTypes = { enums?: SomeEnum | null, map?: Record | null, number?: number | null, + rest?: Record | null, s3_value?: string | null, string?: string | null, vector?: string[] | null, diff --git a/crates/config/tests/snapshots/macros_test__generates_typescript.snap b/crates/config/tests/snapshots/macros_test__generates_typescript.snap index 504f67e6..4842f556 100644 --- a/crates/config/tests/snapshots/macros_test__generates_typescript.snap +++ b/crates/config/tests/snapshots/macros_test__generates_typescript.snap @@ -21,6 +21,7 @@ export interface ValueTypes { enums: SomeEnum; map: Record; number: number; + rest: Record; s3_value: string; string: string; vector: string[]; @@ -152,6 +153,7 @@ export interface PartialValueTypes { enums?: SomeEnum | null; map?: Record | null; number?: number | null; + rest?: Record | null; s3_value?: string | null; string?: string | null; vector?: string[] | null; diff --git a/crates/test-app/Cargo.toml b/crates/test-app/Cargo.toml index 75a83525..580f869b 100644 --- a/crates/test-app/Cargo.toml +++ b/crates/test-app/Cargo.toml @@ -17,4 +17,4 @@ miette = { workspace = true, features = ["fancy"] } regex = { workspace = true } rust_decimal = { workspace = true } serde = { workspace = true } -serde_json = "1.0.108" +serde_json = { workspace = true } diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index b737b447..d2fad91b 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -11,8 +11,9 @@ chrono = { workspace = true, optional = true } regex = { workspace = true, optional = true } rust_decimal = { workspace = true, optional = true } relative-path = { workspace = true, optional = true } -semver = { workspace = true, optional = true } url = { workspace = true, optional = true } +semver = { workspace = true, optional = true } +serde_json = { workspace = true, optional = true } version_spec = { workspace = true, optional = true } warpgate = { workspace = true, optional = true } @@ -23,6 +24,7 @@ schematic_types = { path = ".", features = [ "relative_path", "rust_decimal", "semver", + "serde_json", "url", "version_spec", "warpgate", @@ -35,6 +37,7 @@ regex = ["dep:regex"] relative_path = ["dep:relative-path"] rust_decimal = ["dep:rust_decimal"] semver = ["dep:semver"] +serde_json = ["dep:serde_json"] url = ["dep:url"] version_spec = ["dep:version_spec"] warpgate = ["dep:warpgate"] diff --git a/crates/types/src/externals.rs b/crates/types/src/externals.rs index 95045fa6..11521188 100644 --- a/crates/types/src/externals.rs +++ b/crates/types/src/externals.rs @@ -1,6 +1,16 @@ #![allow(deprecated, unused_imports, unused_macros)] -use crate::{SchemaType, Schematic, StringType}; +use crate::{IntegerKind, SchemaType, Schematic, StringType}; + +macro_rules! impl_unknown { + ($type:ty) => { + impl Schematic for $type { + fn generate_schema() -> SchemaType { + SchemaType::Unknown + } + } + }; +} macro_rules! impl_string { ($type:ty) => { @@ -85,6 +95,26 @@ mod semver_feature { impl_string!(semver::VersionReq); } +#[cfg(feature = "serde_json")] +mod serde_json_feature { + use super::*; + + impl_unknown!(serde_json::Value); + + // This isn't accurate since we can't access the `N` enum + impl Schematic for serde_json::Number { + fn generate_schema() -> SchemaType { + SchemaType::integer(IntegerKind::I64) + } + } + + impl Schematic for serde_json::Map { + fn generate_schema() -> SchemaType { + SchemaType::object(K::generate_schema(), V::generate_schema()) + } + } +} + #[cfg(feature = "url")] mod url_feature { use super::*; From add200f56287cee4dfc9d7b54bd932b7c968fb8e Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 29 Nov 2023 16:33:47 -0800 Subject: [PATCH 4/6] Add serde yaml. --- CHANGELOG.md | 3 ++- Cargo.lock | 1 + Cargo.toml | 1 + README.md | 1 + crates/config/Cargo.toml | 4 +++- crates/config/tests/generator_test.rs | 1 + ...generator_test__json_schema__defaults.snap | 6 ++++- ...nerator_test__typescript__const_enums.snap | 1 + .../generator_test__typescript__defaults.snap | 1 + .../generator_test__typescript__enums.snap | 1 + ...erator_test__typescript__exclude_refs.snap | 1 + ...ator_test__typescript__external_types.snap | 1 + .../generator_test__typescript__no_refs.snap | 1 + ...ator_test__typescript__object_aliases.snap | 1 + ...nerator_test__typescript__value_enums.snap | 1 + crates/types/Cargo.toml | 3 +++ crates/types/src/externals.rs | 23 +++++++++++++++++++ 17 files changed, 48 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06b34792..9c66ee7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ #### 🚀 Updates - Added serde `flatten` support. -- Added `type_serde_json` feature, that implements schematic types for serde values. +- Added `type_serde_json` and `type_serde_yaml` features, that implements schematic types for serde + values. #### ⚙️ Internal diff --git a/Cargo.lock b/Cargo.lock index 18832e37..9aaa7b4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2637,6 +2637,7 @@ dependencies = [ "schematic_types", "semver", "serde_json", + "serde_yaml 0.9.27", "url", "version_spec", "warpgate", diff --git a/Cargo.toml b/Cargo.toml index 0e691aec..7e8e7a3c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ rust_decimal = "1.33.1" semver = "1.0.20" serde = { version = "1.0.193", features = ["derive"] } serde_json = "1.0.108" +serde_yaml = "0.9.27" url = "2.5.0" version_spec = "0.1.5" warpgate = "0.5.14" diff --git a/README.md b/README.md index 7b35dae9..3a96285f 100644 --- a/README.md +++ b/README.md @@ -694,6 +694,7 @@ The following Cargo features are available: - `type_rust_decimal` - Implements schematic for the `rust_decimal` crate. - `type_semver` - Implements schematic for the `semver` crate. - `type_serde_json` - Implements schematic for the `serde_json` crate. +- `type_serde_yaml` - Implements schematic for the `serde_yaml` crate. - `type_url` - Implements schematic for the `url` crate. - `type_version_spec` - Implements schematic for the `version_spec` crate. - `type_warpgate` - Implements schematic for the `warpgate` crate. diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 5a54e411..5fc19e4c 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -43,7 +43,7 @@ schemars = { version = "0.8.16", optional = true, default-features = false } toml = { version = "0.8.8", optional = true } # yaml -serde_yaml = { version = "0.9.27", optional = true } +serde_yaml = { workspace = true, optional = true } # url reqwest = { version = "0.11.22", default-features = false, optional = true, features = [ @@ -73,6 +73,7 @@ type_relative_path = ["schematic_types/relative_path"] type_rust_decimal = ["schematic_types/rust_decimal"] type_semver = ["schematic_types/semver"] type_serde_json = ["schematic_types/serde_json"] +type_serde_yaml = ["schematic_types/serde_yaml"] type_url = ["schematic_types/url"] type_version_spec = ["schematic_types/version_spec"] type_warpgate = ["schematic_types/warpgate"] @@ -94,6 +95,7 @@ schematic = { path = ".", features = [ "type_rust_decimal", "type_semver", "type_serde_json", + "type_serde_yaml", "type_url", "type_version_spec", "type_warpgate", diff --git a/crates/config/tests/generator_test.rs b/crates/config/tests/generator_test.rs index 652a78aa..167895e2 100644 --- a/crates/config/tests/generator_test.rs +++ b/crates/config/tests/generator_test.rs @@ -53,6 +53,7 @@ struct GenConfig { id: warpgate::Id, locator: Option, json_value: serde_json::Value, + yaml_value: serde_yaml::Value, } fn create_generator() -> SchemaGenerator { diff --git a/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap b/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap index 109efe15..53b9339c 100644 --- a/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap +++ b/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap @@ -29,7 +29,8 @@ expression: "fs::read_to_string(file).unwrap()" "url", "vector", "version", - "versionReq" + "versionReq", + "yamlValue" ], "properties": { "boolean": { @@ -145,6 +146,9 @@ expression: "fs::read_to_string(file).unwrap()" }, "versionReq": { "type": "string" + }, + "yamlValue": { + "type": "null" } }, "additionalProperties": false, diff --git a/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap b/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap index 283fa579..9170beed 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap @@ -42,5 +42,6 @@ export interface GenConfig { vector: string[]; version: string | null; versionReq: string; + yamlValue: unknown; } diff --git a/crates/config/tests/snapshots/generator_test__typescript__defaults.snap b/crates/config/tests/snapshots/generator_test__typescript__defaults.snap index 4236f236..fd50c3e9 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__defaults.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__defaults.snap @@ -38,5 +38,6 @@ export interface GenConfig { vector: string[]; version: string | null; versionReq: string; + yamlValue: unknown; } diff --git a/crates/config/tests/snapshots/generator_test__typescript__enums.snap b/crates/config/tests/snapshots/generator_test__typescript__enums.snap index 946ffdd3..a3ad2c78 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__enums.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__enums.snap @@ -42,5 +42,6 @@ export interface GenConfig { vector: string[]; version: string | null; versionReq: string; + yamlValue: unknown; } diff --git a/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap b/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap index 7406b668..2807e8e8 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap @@ -36,5 +36,6 @@ export interface GenConfig { vector: string[]; version: string | null; versionReq: string; + yamlValue: unknown; } diff --git a/crates/config/tests/snapshots/generator_test__typescript__external_types.snap b/crates/config/tests/snapshots/generator_test__typescript__external_types.snap index 75cd344e..c8377b6c 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__external_types.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__external_types.snap @@ -40,5 +40,6 @@ export interface GenConfig { vector: string[]; version: string | null; versionReq: string; + yamlValue: unknown; } diff --git a/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap b/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap index 1f81d7e3..882714d6 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap @@ -41,5 +41,6 @@ export interface GenConfig { vector: string[]; version: string | null; versionReq: string; + yamlValue: unknown; } diff --git a/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap b/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap index 5fb74c9b..fd28c61c 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap @@ -38,5 +38,6 @@ export type GenConfig = { vector: string[], version: string | null, versionReq: string, + yamlValue: unknown, }; diff --git a/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap b/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap index 34b946d9..8646117d 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap @@ -42,5 +42,6 @@ export interface GenConfig { vector: string[]; version: string | null; versionReq: string; + yamlValue: unknown; } diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index d2fad91b..c2587957 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -14,6 +14,7 @@ relative-path = { workspace = true, optional = true } url = { workspace = true, optional = true } semver = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } +serde_yaml = { workspace = true, optional = true } version_spec = { workspace = true, optional = true } warpgate = { workspace = true, optional = true } @@ -25,6 +26,7 @@ schematic_types = { path = ".", features = [ "rust_decimal", "semver", "serde_json", + "serde_yaml", "url", "version_spec", "warpgate", @@ -38,6 +40,7 @@ relative_path = ["dep:relative-path"] rust_decimal = ["dep:rust_decimal"] semver = ["dep:semver"] serde_json = ["dep:serde_json"] +serde_yaml = ["dep:serde_yaml"] url = ["dep:url"] version_spec = ["dep:version_spec"] warpgate = ["dep:warpgate"] diff --git a/crates/types/src/externals.rs b/crates/types/src/externals.rs index 11521188..f6dc3e75 100644 --- a/crates/types/src/externals.rs +++ b/crates/types/src/externals.rs @@ -115,6 +115,29 @@ mod serde_json_feature { } } +#[cfg(feature = "serde_yaml")] +mod serde_yaml_feature { + use super::*; + + impl_unknown!(serde_yaml::Value); + + // This isn't accurate since we can't access the `N` enum + impl Schematic for serde_yaml::Number { + fn generate_schema() -> SchemaType { + SchemaType::integer(IntegerKind::I64) + } + } + + impl Schematic for serde_yaml::Mapping { + fn generate_schema() -> SchemaType { + SchemaType::object( + serde_yaml::Value::generate_schema(), + serde_yaml::Value::generate_schema(), + ) + } + } +} + #[cfg(feature = "url")] mod url_feature { use super::*; From 74b3e4cfd36cd8c25c43b8687303ab585b76a697 Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 29 Nov 2023 16:40:20 -0800 Subject: [PATCH 5/6] Add toml. --- CHANGELOG.md | 4 ++-- Cargo.lock | 1 + Cargo.toml | 1 + README.md | 1 + crates/config/Cargo.toml | 4 +++- crates/config/tests/generator_test.rs | 1 + .../generator_test__json_schema__defaults.snap | 11 +++++++++++ .../generator_test__typescript__const_enums.snap | 1 + .../generator_test__typescript__defaults.snap | 1 + .../generator_test__typescript__enums.snap | 1 + .../generator_test__typescript__exclude_refs.snap | 1 + .../generator_test__typescript__external_types.snap | 1 + .../generator_test__typescript__no_refs.snap | 1 + .../generator_test__typescript__object_aliases.snap | 1 + .../generator_test__typescript__value_enums.snap | 1 + crates/types/Cargo.toml | 3 +++ crates/types/src/externals.rs | 13 +++++++++++++ 17 files changed, 44 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c66ee7e..1ef9da92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,8 +5,8 @@ #### 🚀 Updates - Added serde `flatten` support. -- Added `type_serde_json` and `type_serde_yaml` features, that implements schematic types for serde - values. +- Added `type_serde_json`, `type_serde_toml`, and `type_serde_yaml` features, that implements + schematic types for serde values. #### ⚙️ Internal diff --git a/Cargo.lock b/Cargo.lock index 9aaa7b4d..cdad49bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2638,6 +2638,7 @@ dependencies = [ "semver", "serde_json", "serde_yaml 0.9.27", + "toml 0.8.8", "url", "version_spec", "warpgate", diff --git a/Cargo.toml b/Cargo.toml index 7e8e7a3c..38e59061 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,6 +12,7 @@ semver = "1.0.20" serde = { version = "1.0.193", features = ["derive"] } serde_json = "1.0.108" serde_yaml = "0.9.27" +toml = "0.8.8" url = "2.5.0" version_spec = "0.1.5" warpgate = "0.5.14" diff --git a/README.md b/README.md index 3a96285f..db78e926 100644 --- a/README.md +++ b/README.md @@ -694,6 +694,7 @@ The following Cargo features are available: - `type_rust_decimal` - Implements schematic for the `rust_decimal` crate. - `type_semver` - Implements schematic for the `semver` crate. - `type_serde_json` - Implements schematic for the `serde_json` crate. +- `type_serde_toml` - Implements schematic for the `toml` crate. - `type_serde_yaml` - Implements schematic for the `serde_yaml` crate. - `type_url` - Implements schematic for the `url` crate. - `type_version_spec` - Implements schematic for the `version_spec` crate. diff --git a/crates/config/Cargo.toml b/crates/config/Cargo.toml index 5fc19e4c..a1651308 100644 --- a/crates/config/Cargo.toml +++ b/crates/config/Cargo.toml @@ -40,7 +40,7 @@ serde_json = { workspace = true, optional = true } schemars = { version = "0.8.16", optional = true, default-features = false } # toml -toml = { version = "0.8.8", optional = true } +toml = { workspace = true, optional = true } # yaml serde_yaml = { workspace = true, optional = true } @@ -73,6 +73,7 @@ type_relative_path = ["schematic_types/relative_path"] type_rust_decimal = ["schematic_types/rust_decimal"] type_semver = ["schematic_types/semver"] type_serde_json = ["schematic_types/serde_json"] +type_serde_toml = ["schematic_types/serde_toml"] type_serde_yaml = ["schematic_types/serde_yaml"] type_url = ["schematic_types/url"] type_version_spec = ["schematic_types/version_spec"] @@ -95,6 +96,7 @@ schematic = { path = ".", features = [ "type_rust_decimal", "type_semver", "type_serde_json", + "type_serde_toml", "type_serde_yaml", "type_url", "type_version_spec", diff --git a/crates/config/tests/generator_test.rs b/crates/config/tests/generator_test.rs index 167895e2..5218adb0 100644 --- a/crates/config/tests/generator_test.rs +++ b/crates/config/tests/generator_test.rs @@ -53,6 +53,7 @@ struct GenConfig { id: warpgate::Id, locator: Option, json_value: serde_json::Value, + toml_value: Option, yaml_value: serde_yaml::Value, } diff --git a/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap b/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap index 53b9339c..9e02bc2a 100644 --- a/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap +++ b/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap @@ -26,6 +26,7 @@ expression: "fs::read_to_string(file).unwrap()" "specUnresolved", "string", "time", + "tomlValue", "url", "vector", "version", @@ -117,6 +118,16 @@ expression: "fs::read_to_string(file).unwrap()" "type": "string", "format": "time" }, + "tomlValue": { + "anyOf": [ + { + "type": "null" + }, + { + "type": "null" + } + ] + }, "url": { "anyOf": [ { diff --git a/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap b/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap index 9170beed..faa19d47 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__const_enums.snap @@ -38,6 +38,7 @@ export interface GenConfig { specUnresolved: string; string: string; time: string; + tomlValue: unknown | null; url: string | null; vector: string[]; version: string | null; diff --git a/crates/config/tests/snapshots/generator_test__typescript__defaults.snap b/crates/config/tests/snapshots/generator_test__typescript__defaults.snap index fd50c3e9..968923e6 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__defaults.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__defaults.snap @@ -34,6 +34,7 @@ export interface GenConfig { specUnresolved: string; string: string; time: string; + tomlValue: unknown | null; url: string | null; vector: string[]; version: string | null; diff --git a/crates/config/tests/snapshots/generator_test__typescript__enums.snap b/crates/config/tests/snapshots/generator_test__typescript__enums.snap index a3ad2c78..04b87646 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__enums.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__enums.snap @@ -38,6 +38,7 @@ export interface GenConfig { specUnresolved: string; string: string; time: string; + tomlValue: unknown | null; url: string | null; vector: string[]; version: string | null; diff --git a/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap b/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap index 2807e8e8..915ee83e 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__exclude_refs.snap @@ -32,6 +32,7 @@ export interface GenConfig { specUnresolved: string; string: string; time: string; + tomlValue: unknown | null; url: string | null; vector: string[]; version: string | null; diff --git a/crates/config/tests/snapshots/generator_test__typescript__external_types.snap b/crates/config/tests/snapshots/generator_test__typescript__external_types.snap index c8377b6c..a3e34751 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__external_types.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__external_types.snap @@ -36,6 +36,7 @@ export interface GenConfig { specUnresolved: string; string: string; time: string; + tomlValue: unknown | null; url: string | null; vector: string[]; version: string | null; diff --git a/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap b/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap index 882714d6..2fe80fcc 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__no_refs.snap @@ -37,6 +37,7 @@ export interface GenConfig { specUnresolved: string; string: string; time: string; + tomlValue: unknown | null; url: string | null; vector: string[]; version: string | null; diff --git a/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap b/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap index fd28c61c..d2239598 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__object_aliases.snap @@ -34,6 +34,7 @@ export type GenConfig = { specUnresolved: string, string: string, time: string, + tomlValue: unknown | null, url: string | null, vector: string[], version: string | null, diff --git a/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap b/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap index 8646117d..2c6bd86d 100644 --- a/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap +++ b/crates/config/tests/snapshots/generator_test__typescript__value_enums.snap @@ -38,6 +38,7 @@ export interface GenConfig { specUnresolved: string; string: string; time: string; + tomlValue: unknown | null; url: string | null; vector: string[]; version: string | null; diff --git a/crates/types/Cargo.toml b/crates/types/Cargo.toml index c2587957..fb83c3ff 100644 --- a/crates/types/Cargo.toml +++ b/crates/types/Cargo.toml @@ -15,6 +15,7 @@ url = { workspace = true, optional = true } semver = { workspace = true, optional = true } serde_json = { workspace = true, optional = true } serde_yaml = { workspace = true, optional = true } +toml = { workspace = true, optional = true } version_spec = { workspace = true, optional = true } warpgate = { workspace = true, optional = true } @@ -26,6 +27,7 @@ schematic_types = { path = ".", features = [ "rust_decimal", "semver", "serde_json", + "serde_toml", "serde_yaml", "url", "version_spec", @@ -40,6 +42,7 @@ relative_path = ["dep:relative-path"] rust_decimal = ["dep:rust_decimal"] semver = ["dep:semver"] serde_json = ["dep:serde_json"] +serde_toml = ["dep:toml"] serde_yaml = ["dep:serde_yaml"] url = ["dep:url"] version_spec = ["dep:version_spec"] diff --git a/crates/types/src/externals.rs b/crates/types/src/externals.rs index f6dc3e75..862f4ee4 100644 --- a/crates/types/src/externals.rs +++ b/crates/types/src/externals.rs @@ -115,6 +115,19 @@ mod serde_json_feature { } } +#[cfg(feature = "serde_toml")] +mod serde_toml_feature { + use super::*; + + impl_unknown!(toml::Value); + + impl Schematic for toml::map::Map { + fn generate_schema() -> SchemaType { + SchemaType::object(K::generate_schema(), V::generate_schema()) + } + } +} + #[cfg(feature = "serde_yaml")] mod serde_yaml_feature { use super::*; From b49a19c44bec5313dc8215da2ed6b957b261c01f Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Wed, 29 Nov 2023 16:48:18 -0800 Subject: [PATCH 6/6] Fix unknown. --- CHANGELOG.md | 4 +++ .../src/schema/renderers/json_schema.rs | 9 ++++++- ...generator_test__json_schema__defaults.snap | 27 ++++++++++++++++--- .../macros_test__generates_json_schema.snap | 18 +++++++++++-- 4 files changed, 52 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ef9da92..bc98516a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ - Added `type_serde_json`, `type_serde_toml`, and `type_serde_yaml` features, that implements schematic types for serde values. +#### 🐞 Fixes + +- Updated json schema unknown/any type to be a union of all types, instead of null. + #### ⚙️ Internal - Updated dependencies. diff --git a/crates/config/src/schema/renderers/json_schema.rs b/crates/config/src/schema/renderers/json_schema.rs index f39baffb..8752fdeb 100644 --- a/crates/config/src/schema/renderers/json_schema.rs +++ b/crates/config/src/schema/renderers/json_schema.rs @@ -355,7 +355,14 @@ impl SchemaRenderer for JsonSchemaRenderer { fn render_unknown(&mut self) -> RenderResult { Ok(Schema::Object(SchemaObject { - instance_type: Some(SingleOrVec::Single(Box::new(InstanceType::Null))), + instance_type: Some(SingleOrVec::Vec(vec![ + InstanceType::Boolean, + InstanceType::Object, + InstanceType::Array, + InstanceType::Number, + InstanceType::String, + InstanceType::Integer, + ])), ..Default::default() })) } diff --git a/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap b/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap index 9e02bc2a..2810d31f 100644 --- a/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap +++ b/crates/config/tests/snapshots/generator_test__json_schema__defaults.snap @@ -66,7 +66,14 @@ expression: "fs::read_to_string(file).unwrap()" "type": "string" }, "jsonValue": { - "type": "null" + "type": [ + "boolean", + "object", + "array", + "number", + "string", + "integer" + ] }, "locator": { "anyOf": [ @@ -121,7 +128,14 @@ expression: "fs::read_to_string(file).unwrap()" "tomlValue": { "anyOf": [ { - "type": "null" + "type": [ + "boolean", + "object", + "array", + "number", + "string", + "integer" + ] }, { "type": "null" @@ -159,7 +173,14 @@ expression: "fs::read_to_string(file).unwrap()" "type": "string" }, "yamlValue": { - "type": "null" + "type": [ + "boolean", + "object", + "array", + "number", + "string", + "integer" + ] } }, "additionalProperties": false, diff --git a/crates/config/tests/snapshots/macros_test__generates_json_schema.snap b/crates/config/tests/snapshots/macros_test__generates_json_schema.snap index 4b044094..5a5f52c1 100644 --- a/crates/config/tests/snapshots/macros_test__generates_json_schema.snap +++ b/crates/config/tests/snapshots/macros_test__generates_json_schema.snap @@ -696,7 +696,14 @@ expression: "std::fs::read_to_string(file).unwrap()" { "type": "object", "additionalProperties": { - "type": "null" + "type": [ + "boolean", + "object", + "array", + "number", + "string", + "integer" + ] }, "propertyNames": { "type": "string" @@ -869,7 +876,14 @@ expression: "std::fs::read_to_string(file).unwrap()" "rest": { "type": "object", "additionalProperties": { - "type": "null" + "type": [ + "boolean", + "object", + "array", + "number", + "string", + "integer" + ] }, "propertyNames": { "type": "string"