diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-02-09 23:02:42 +0100 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-02-09 23:02:42 +0100 |
commit | 4d63cd09c1d97480c14be80a74e49f5f4134b340 (patch) | |
tree | ad073ee391e6cc1c82e119fce55fdcec6c281715 /generator | |
parent | better documentation for body params (diff) | |
download | forgejo-api-4d63cd09c1d97480c14be80a74e49f5f4134b340.tar.xz forgejo-api-4d63cd09c1d97480c14be80a74e49f5f4134b340.zip |
better document structs
Diffstat (limited to 'generator')
-rw-r--r-- | generator/src/structs.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/generator/src/structs.rs b/generator/src/structs.rs index 1d07ab4..45e2f71 100644 --- a/generator/src/structs.rs +++ b/generator/src/structs.rs @@ -65,6 +65,15 @@ pub fn create_struct_for_definition( if field_ty == "Option<time::OffsetDateTime>" { fields.push_str("#[serde(with = \"time::serde::rfc3339::option\")]\n"); } + if let MaybeRef::Value { value } = &prop_schema { + if let Some(desc) = &value.description { + for line in desc.lines() { + fields.push_str("/// "); + fields.push_str(line); + fields.push_str("\n/// \n"); + } + } + } if &field_name != prop_name { fields.push_str("#[serde(rename = \""); fields.push_str(prop_name); @@ -159,6 +168,13 @@ fn create_query_struct(op: &Operation) -> eyre::Result<String> { if let ParameterIn::Query { param: query_param } = ¶m._in { let ty = crate::methods::param_type(query_param, true)?; let field_name = crate::sanitize_ident(¶m.name); + if let Some(desc) = ¶m.description { + for line in desc.lines() { + fields.push_str("/// "); + fields.push_str(line); + fields.push_str("\n/// \n"); + } + } fields.push_str("pub "); fields.push_str(&field_name); fields.push_str(": "); |