diff options
author | Cyborus <cyborus@cyborus.xyz> | 2024-02-09 22:10:02 +0100 |
---|---|---|
committer | Cyborus <cyborus@cyborus.xyz> | 2024-02-09 22:10:02 +0100 |
commit | 11c07987750c0ee28377b71b63b05cdb10fc0d2c (patch) | |
tree | 49aee80c6768bd8ee58b342d45f5ac0d0bd621c2 /generator | |
parent | deref params in method doc generation (diff) | |
download | forgejo-api-11c07987750c0ee28377b71b63b05cdb10fc0d2c.tar.xz forgejo-api-11c07987750c0ee28377b71b63b05cdb10fc0d2c.zip |
better documentation for body params
Diffstat (limited to 'generator')
-rw-r--r-- | generator/src/methods.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/generator/src/methods.rs b/generator/src/methods.rs index 0cacbe7..064f40a 100644 --- a/generator/src/methods.rs +++ b/generator/src/methods.rs @@ -1,4 +1,4 @@ -use crate::openapi::*; +use crate::{openapi::*, schema_ref_type_name}; use eyre::{OptionExt, WrapErr}; use heck::ToSnakeCase; use std::fmt::Write; @@ -102,9 +102,8 @@ fn method_docs(spec: &OpenApiV2, op: &Operation) -> eyre::Result<String> { } for param in params { let param = param.deref(spec)?; - match param._in { + match ¶m._in { ParameterIn::Path { param: _ } - | ParameterIn::Body { schema: _ } | ParameterIn::FormData { param: _ } => { write!(&mut out, "/// - `{}`", param.name)?; if let Some(description) = ¶m.description { @@ -112,6 +111,16 @@ fn method_docs(spec: &OpenApiV2, op: &Operation) -> eyre::Result<String> { } writeln!(&mut out)?; } + ParameterIn::Body { schema } => { + write!(&mut out, "/// - `{}`", param.name)?; + let ty = schema_ref_type_name(spec, &schema)?; + if let Some(description) = ¶m.description { + write!(&mut out, ": {}\n\n/// See [`{}`]", description, ty)?; + } else { + write!(&mut out, ": See [`{}`]", ty)?; + } + writeln!(&mut out)?; + } _ => (), } } |