From 8192601931983c69edcb336d063b4869bf6183f7 Mon Sep 17 00:00:00 2001 From: "Adam H. Leventhal" Date: Thu, 20 Aug 2026 10:14:22 -0700 Subject: [PATCH] improve marginal test json input --- typify-impl/src/type_entry.rs | 6 ++- typify/tests/schemas/arrays-and-tuples.json | 12 +++++- typify/tests/schemas/arrays-and-tuples.rs | 48 ++++++++++++++++++--- 3 files changed, 55 insertions(+), 11 deletions(-) diff --git a/typify-impl/src/type_entry.rs b/typify-impl/src/type_entry.rs index 458c1c07..4ad8ea1e 100644 --- a/typify-impl/src/type_entry.rs +++ b/typify-impl/src/type_entry.rs @@ -1806,7 +1806,9 @@ impl TypeEntry { if key_ty.details == TypeEntryDetails::String && value_ty.details == TypeEntryDetails::JsonValue { - quote! { ::serde_json::Map<::std::string::String, ::serde_json::Value> } + quote! { + ::serde_json::Map<::std::string::String, ::serde_json::Value> + } } else { let key_ident = key_ty.type_ident(type_space, type_mod); let value_ident = value_ty.type_ident(type_space, type_mod); @@ -1824,7 +1826,7 @@ impl TypeEntry { let item = inner_ty.type_ident(type_space, type_mod); // TODO we'll want this to be a Set of some kind, but we need // to get the derives right first. - quote! { Vec<#item> } + quote! { ::std::vec::Vec<#item> } } TypeEntryDetails::Tuple(items) => { diff --git a/typify/tests/schemas/arrays-and-tuples.json b/typify/tests/schemas/arrays-and-tuples.json index 5d040148..70b6b4af 100644 --- a/typify/tests/schemas/arrays-and-tuples.json +++ b/typify/tests/schemas/arrays-and-tuples.json @@ -63,7 +63,15 @@ "array-sans-items": { "type": "array", "minItems": 1, - "uniqueItems": true + "uniqueItems": false + }, + "set-avec-item": { + "type": "array", + "minItems": 1, + "uniqueItems": true, + "items": { + "type": "string" + } } } -} \ No newline at end of file +} diff --git a/typify/tests/schemas/arrays-and-tuples.rs b/typify/tests/schemas/arrays-and-tuples.rs index 7a741a74..d4fee2c7 100644 --- a/typify/tests/schemas/arrays-and-tuples.rs +++ b/typify/tests/schemas/arrays-and-tuples.rs @@ -33,26 +33,26 @@ pub mod error { #[doc = "{"] #[doc = " \"type\": \"array\","] #[doc = " \"minItems\": 1,"] -#[doc = " \"uniqueItems\": true"] +#[doc = " \"uniqueItems\": false"] #[doc = "}"] #[doc = r" ```"] #[doc = r" "] #[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] #[serde(transparent)] -pub struct ArraySansItems(pub Vec<::serde_json::Value>); +pub struct ArraySansItems(pub ::std::vec::Vec<::serde_json::Value>); impl ::std::ops::Deref for ArraySansItems { - type Target = Vec<::serde_json::Value>; - fn deref(&self) -> &Vec<::serde_json::Value> { + type Target = ::std::vec::Vec<::serde_json::Value>; + fn deref(&self) -> &::std::vec::Vec<::serde_json::Value> { &self.0 } } -impl ::std::convert::From for Vec<::serde_json::Value> { +impl ::std::convert::From for ::std::vec::Vec<::serde_json::Value> { fn from(value: ArraySansItems) -> Self { value.0 } } -impl ::std::convert::From> for ArraySansItems { - fn from(value: Vec<::serde_json::Value>) -> Self { +impl ::std::convert::From<::std::vec::Vec<::serde_json::Value>> for ArraySansItems { + fn from(value: ::std::vec::Vec<::serde_json::Value>) -> Self { Self(value) } } @@ -98,6 +98,40 @@ impl ::std::convert::From<(::std::string::String, ::std::string::String)> for Le Self(value) } } +#[doc = "`SetAvecItem`"] +#[doc = r""] +#[doc = r"
JSON schema"] +#[doc = r""] +#[doc = r" ```json"] +#[doc = "{"] +#[doc = " \"type\": \"array\","] +#[doc = " \"items\": {"] +#[doc = " \"type\": \"string\""] +#[doc = " },"] +#[doc = " \"minItems\": 1,"] +#[doc = " \"uniqueItems\": true"] +#[doc = "}"] +#[doc = r" ```"] +#[doc = r"
"] +#[derive(:: serde :: Deserialize, :: serde :: Serialize, Clone, Debug)] +#[serde(transparent)] +pub struct SetAvecItem(pub ::std::vec::Vec<::std::string::String>); +impl ::std::ops::Deref for SetAvecItem { + type Target = ::std::vec::Vec<::std::string::String>; + fn deref(&self) -> &::std::vec::Vec<::std::string::String> { + &self.0 + } +} +impl ::std::convert::From for ::std::vec::Vec<::std::string::String> { + fn from(value: SetAvecItem) -> Self { + value.0 + } +} +impl ::std::convert::From<::std::vec::Vec<::std::string::String>> for SetAvecItem { + fn from(value: ::std::vec::Vec<::std::string::String>) -> Self { + Self(value) + } +} #[doc = "`SimpleTwoArray`"] #[doc = r""] #[doc = r"
JSON schema"]