diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-03-15 23:13:24 +0100 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-03-15 23:13:24 +0100 |
commit | cad68901287659878419a50568496ed3b201097a (patch) | |
tree | b77d041c1cd44097b3bff36123b84820e57ed0a5 /generator | |
parent | adjust created user's email in test (diff) | |
download | forgejo-api-cad68901287659878419a50568496ed3b201097a.tar.xz forgejo-api-cad68901287659878419a50568496ed3b201097a.zip |
remove structs that only exist for their `additional` field
Diffstat (limited to 'generator')
-rw-r--r-- | generator/src/main.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/generator/src/main.rs b/generator/src/main.rs index 8b6272e..9a5abee 100644 --- a/generator/src/main.rs +++ b/generator/src/main.rs @@ -203,17 +203,27 @@ fn schema_subtype_name( let b = match schema { Schema { _type: Some(SchemaType::One(Primitive::Object)), + properties: Some(_), + .. + } + | Schema { + _type: Some(SchemaType::One(Primitive::String)), + _enum: Some(_), .. } => { *ty = format!("{parent_name}{}", name.to_pascal_case()); true } Schema { - _type: Some(SchemaType::One(Primitive::String)), - _enum: Some(_enum), + _type: Some(SchemaType::One(Primitive::Object)), + properties: None, + additional_properties: Some(additional), .. } => { - *ty = format!("{parent_name}{}", name.to_pascal_case()); + let additional = additional.deref(spec)?; + let mut additional_ty = crate::schema_type_name(spec, None, additional)?; + schema_subtype_name(spec, parent_name, name, additional, &mut additional_ty)?; + *ty = format!("std::collections::BTreeMap<String, {additional_ty}>"); true } Schema { @@ -246,6 +256,7 @@ fn schema_subtypes( match schema { Schema { _type: Some(SchemaType::One(Primitive::Object)), + properties: Some(_), .. } => { let name = format!("{parent_name}{}", name.to_pascal_case()); |