From 11c07987750c0ee28377b71b63b05cdb10fc0d2c Mon Sep 17 00:00:00 2001 From: Cyborus Date: Fri, 9 Feb 2024 16:10:02 -0500 Subject: better documentation for body params --- generator/src/methods.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'generator') 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 { } 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 { } 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)?; + } _ => (), } } -- cgit v1.2.3