summaryrefslogtreecommitdiffstats
path: root/generator/src/main.rs
diff options
context:
space:
mode:
authorCyborus <cyborus@cyborus.xyz>2024-01-17 00:09:13 +0100
committerCyborus <cyborus@cyborus.xyz>2024-01-17 00:09:13 +0100
commit70b4081cde6504d1c1cdb05b9f3d34c841ece2f5 (patch)
treee28bc3a849f7fccc6c1349124122a4b28fcf87cc /generator/src/main.rs
parentadd missing arg to `UnexpectedStatusCode` (diff)
downloadforgejo-api-70b4081cde6504d1c1cdb05b9f3d34c841ece2f5.tar.xz
forgejo-api-70b4081cde6504d1c1cdb05b9f3d34c841ece2f5.zip
simple recursion prevention
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(": ");