better documentation for body params
This commit is contained in:
parent
7bab7c4a5f
commit
11c0798775
2 changed files with 113 additions and 98 deletions
|
@ -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)?;
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue