summaryrefslogtreecommitdiffstats
path: root/generator/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--generator/src/main.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/generator/src/main.rs b/generator/src/main.rs
index 44911b9..cb34843 100644
--- a/generator/src/main.rs
+++ b/generator/src/main.rs
@@ -705,10 +705,11 @@ fn create_struct_for_definition(
for (prop_name, prop_schema) in properties {
let prop_ty = schema_ref_type_name(spec, prop_schema)?;
let field_name = sanitize_ident(prop_name);
- let field_ty = if required.contains(prop_name) {
- prop_ty
- } else {
- format!("Option<{prop_ty}>")
+ let field_ty = match (!required.contains(prop_name), prop_ty == name) {
+ (false, false) => prop_ty,
+ (false, true) => format!("Box<{prop_ty}>"),
+ (true, false) => format!("Option<{prop_ty}>"),
+ (true, true) => format!("Option<Box<{prop_ty}>>"),
};
fields.push_str(&field_name);
fields.push_str(": ");