Skip to content

Support mapping <returns> to response description #61920

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2025
Merged

Conversation

captainsafia
Copy link
Member

Closes #61875.

This pull request enhances the handling of XML comments in OpenAPI operations by introducing support for <returns> and <response> tags. It ensures that these tags are correctly applied to operations with single or multiple response values, improving the generated OpenAPI documentation. Additionally, the changes include updates to tests and snapshots to validate the new behavior.

Enhancements to XML Comment Handling:

  • Added logic to apply <returns> tags to operations with a single response value, setting the response description to the <returns> content. (src/OpenApi/gen/XmlCommentGenerator.Emitter.cs, [src/OpenApi/gen/XmlCommentGenerator.Emitter.csR375-R381](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-ccf1c2147f9ea676bdeaf8a0b062fc74276a1a893e4d0a6ef1fb56c96238162fR375-R381))

Test Updates:

  • Updated test cases in OperationTests.MinimalApis.cs to include <returns> and <response> tags in XML comments for various methods. ([[1]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-cbc2066e28b3f7018a9c4e5f6f4f59f9127c8e288588fad01a21bd6ebfaafa2eR58), [[2]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-cbc2066e28b3f7018a9c4e5f6f4f59f9127c8e288588fad01a21bd6ebfaafa2eR77-R84), [[3]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-cbc2066e28b3f7018a9c4e5f6f4f59f9127c8e288588fad01a21bd6ebfaafa2eR180), [[4]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-cbc2066e28b3f7018a9c4e5f6f4f59f9127c8e288588fad01a21bd6ebfaafa2eR189))
  • Added assertions in tests to verify that <returns> and <response> descriptions are correctly reflected in the OpenAPI documentation. ([[1]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-cbc2066e28b3f7018a9c4e5f6f4f59f9127c8e288588fad01a21bd6ebfaafa2eR242), [[2]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-cbc2066e28b3f7018a9c4e5f6f4f59f9127c8e288588fad01a21bd6ebfaafa2eR294-R298))

Snapshot Updates:

  • Updated multiple snapshot files to reflect the new behavior of <returns> and <response> handling in OpenAPI documentation. ([[1]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-91078e9702b9a55fe1478810252bc53840a02f9ec275358e87290d4950643d99R357-R363), [[2]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-6cb2107c6fba63ce6c32d3b4424c02829aa35cef07e10cd61f092e76c1cf2f1aR386-R392), [[3]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-f064ebd886f03280e4efcd140628d796a13e49aaa10f4c20188838a990a37741R476-R482), [[4]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-bda468be16591f7a2a3bf7c0e2e2d046b6782d19671195bec1872d574710f6e7R361-R367), [[5]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-0622f0edd663548006798f175b67c7aae385ff0fedfddc3c088d4cb83804b0d2R379-R385), [[6]](https://github.com/dotnet/aspnetcore/pull/61920/files#diff-dd65270661ebbe5d36535c06b2090a880101451ed1e4e9d9ba796348aaeb7945R387-R393))

@captainsafia captainsafia requested a review from a team as a code owner May 13, 2025 19:32
@captainsafia captainsafia added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc labels May 13, 2025
@captainsafia captainsafia enabled auto-merge (squash) May 14, 2025 20:54
@captainsafia captainsafia merged commit debb78a into main May 15, 2025
27 checks passed
@captainsafia captainsafia deleted the safia/xml-async branch May 15, 2025 00:03
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview5 milestone May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-openapi
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OpenApi] xml doc not used when endpoint delegate is async
2 participants