From 77bb93c19d132b07a96b04dc8bc5c82459da41ef Mon Sep 17 00:00:00 2001 From: Bruno Date: Mon, 25 Nov 2024 03:28:49 +0100 Subject: [PATCH] Assign the description to the request object in OpenAPI (#886) 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; + } } });