You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently, there is no rust equivalent of my_struct being generated. Instead just for every type inside my_struct. Is there maybe an issue with the schema?
Is it somehow possible to prevent generating wrapper types for types like Double etc and just use equivalent types directly?
To demonstrate the latter: I pasted the schema to quicktype and the result seems quite idiomatic:
use serde::{Serialize,Deserialize};use std::collections::HashMap;#[derive(Debug,Clone,Serialize,Deserialize)]pubstructMyStruct{arr:Option<Vec<i64>>,d:Option<f64>,hello:Option<String>,i:Option<i64>,map:Option<HashMap<String,i64>>,}
(note: one can get rid of generating all the values as Option by adding "required": ["arr", "d", "hello", "i", "map"], )
Agreed that the quicktype output is better in many ways. We make the choice of wrapping named types in a newtype struct with the expectation that the name in the schema is potentially significant. I could imagine a mode that's more aggressive about inlining, smarter about detecting when named types are shared, or simply making this configurable. There is no such feature today; I would suggest pre-processing the schema to inline referenced types if that's desirable.
Note that quicktype's modeling of std::array<uint64_t,3> does seem a bit less stringent than what typify outputs:
Activity
ahl commentedon Jul 8, 2025
If you add a
titleto the schema, you'll get this type:Or with
requiredas you suggest:Agreed that the quicktype output is better in many ways. We make the choice of wrapping named types in a newtype struct with the expectation that the name in the schema is potentially significant. I could imagine a mode that's more aggressive about inlining, smarter about detecting when named types are shared, or simply making this configurable. There is no such feature today; I would suggest pre-processing the schema to inline referenced types if that's desirable.
Note that quicktype's modeling of
std::array<uint64_t,3>does seem a bit less stringent than what typify outputs: