From 8f3032659b92deaaba8b22fd96b3830a11d1b409 Mon Sep 17 00:00:00 2001 From: Bruno Date: Tue, 17 Sep 2024 14:48:54 +0200 Subject: [PATCH] Assign the description to the request object in OpenAPI This fixes an issue where the doc comment description of an e.g. JSON parameter of a request would not show up in the generated API spec. --- poem-openapi-derive/src/api.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/poem-openapi-derive/src/api.rs b/poem-openapi-derive/src/api.rs index 03487d2730..ae29723d85 100644 --- a/poem-openapi-derive/src/api.rs +++ b/poem-openapi-derive/src/api.rs @@ -396,9 +396,13 @@ fn generate_operation( }); // request object meta + let param_desc = optional_literal(¶m_description); request_meta.push(quote! { if <#arg_ty as #crate_name::ApiExtractor>::TYPES.contains(&#crate_name::ApiExtractorType::RequestObject) { request = <#arg_ty as #crate_name::ApiExtractor>::request_meta(); + if let Some(ref mut request) = request.as_mut() { + request.description = #param_desc; + } } });