Skip to content

How to use XML comments with Minimal APIs? #24659

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

Closed
julioct opened this issue Jan 18, 2022 · 7 comments
Closed

How to use XML comments with Minimal APIs? #24659

julioct opened this issue Jan 18, 2022 · 7 comments
Labels
needs-more-info Source - Docs.ms Docs Customer feedback via GitHub Issue

Comments

@julioct
Copy link

julioct commented Jan 18, 2022

The XML comments section describes how to generate an XML comments file using SwaggerGen options but all the examples are based in XML comments placed in MVC controller methods as opposed to minimal APIs.

How can I generate the summary element in the Swagger JSON file so the Swagger UI doc presents XML comments as documentation for each of the operations?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@dotnet-bot dotnet-bot added ⌚ Not Triaged Source - Docs.ms Docs Customer feedback via GitHub Issue labels Jan 18, 2022
@Rick-Anderson
Copy link
Contributor

@rafikiassumani-msft How to use XML comments with Minimal APIs?

@serpent5
Copy link
Contributor

serpent5 commented Jan 27, 2022

@Rick-Anderson FYI, I saw David Fowler comment on Stack Overflow that this isn't supported.

@julioct
Copy link
Author

julioct commented Jan 27, 2022

@Rick-Anderson @serpent5 @davidfowl If XML comments aren't supported for minimal APIs, how can I get the same effect using any other available method? Looks like all I need is for the generated JSON to include a Summary element, as in the example on the page:

"delete": {
    "tags": [
        "Todo"
    ],
    "summary": "Deletes a specific TodoItem.",
    "parameters": [
    ],
    "responses": {
        "200": {
            "description": "Success"
        }
    }
},

Any way I can generate that Summary element using any other Minimal API available method?

@Rick-Anderson
Copy link
Contributor

Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog manageable. If you believe there is a concern which hasn't been addressed, please file a new issue.

@davidfowl
Copy link
Member

cc @captainsafia

@Rick-Anderson Rick-Anderson reopened this Jun 4, 2022
@captainsafia
Copy link
Member

Any way I can generate that Summary element using any other Minimal API available method?

In the latest .NET 7 preview, you can use the new WithSummary description method on your endpoint or the WithOpenApi extension method. Documentation is here.

With regard to XML docs specifically, we are tracking this at dotnet/aspnetcore#39927. There are some workarounds in the linked issues.

@Rick-Anderson
Copy link
Contributor

Thanks for contacting us. We believe that the question you've raised have been answered. If you still feel a need to continue the discussion, feel free to reopen it and add your comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-more-info Source - Docs.ms Docs Customer feedback via GitHub Issue
Projects
None yet
Development

No branches or pull requests

6 participants