Skip to content

Commit

Permalink
Assign the description to the request object in OpenAPI (#886)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bruwozniak authored Nov 25, 2024
1 parent 2d335ea commit 77bb93c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions poem-openapi-derive/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,13 @@ fn generate_operation(
});

// request object meta
let param_desc = optional_literal(&param_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;
}
}
});

Expand Down

0 comments on commit 77bb93c

Please sign in to comment.