1
0
Fork 0

simple recursion prevention

This commit is contained in:
Cyborus 2024-01-16 18:09:13 -05:00
parent 2859fd132e
commit 70b4081cde
No known key found for this signature in database

View file

@ -705,10 +705,11 @@ fn create_struct_for_definition(
for (prop_name, prop_schema) in properties { for (prop_name, prop_schema) in properties {
let prop_ty = schema_ref_type_name(spec, prop_schema)?; let prop_ty = schema_ref_type_name(spec, prop_schema)?;
let field_name = sanitize_ident(prop_name); let field_name = sanitize_ident(prop_name);
let field_ty = if required.contains(prop_name) { let field_ty = match (!required.contains(prop_name), prop_ty == name) {
prop_ty (false, false) => prop_ty,
} else { (false, true) => format!("Box<{prop_ty}>"),
format!("Option<{prop_ty}>") (true, false) => format!("Option<{prop_ty}>"),
(true, true) => format!("Option<Box<{prop_ty}>>"),
}; };
fields.push_str(&field_name); fields.push_str(&field_name);
fields.push_str(": "); fields.push_str(": ");