Skip to content
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

Question: could I include the controller xml documentation? #4215

Closed
WeihanLi opened this issue Nov 7, 2022 · 8 comments
Closed

Question: could I include the controller xml documentation? #4215

WeihanLi opened this issue Nov 7, 2022 · 8 comments

Comments

@WeihanLi
Copy link

WeihanLi commented Nov 7, 2022

Hi there, could we include the controller xml documentation?
I had configured the project file to generate the xml documentation file, while it does not work for the controller documentation

@ovska
Copy link
Contributor

ovska commented Nov 16, 2022

Did you remember to include the documentation in the swagger doc? I don't think this is a NSwag problem.

For example, using Swashbuckle:

services.AddSwaggerGen(
    options =>
    {
        var filePath = Path.Combine(
            AppContext.BaseDirectory,
            $"{typeof(Startup).Assembly.GetName().Name}.xml");
        options.IncludeXmlComments(filePath);
        // ...
    });

@WeihanLi
Copy link
Author

WeihanLi commented Nov 17, 2022

Did you remember to include the documentation in the swagger doc

@ovska I do generate the xml documentation file, while find no API to include the xml documentation,
and besides, I can see the documentation for the action method

@StingyJack
Copy link

@WeihanLi - I get the controller documentation in the swagger doc

image

And they are also on the generated client.
image

Are you referring to something else? If so, can you give an example?

@WeihanLi
Copy link
Author

Hi @StingyJack , that's documentation comment from the action method, I can get that also, while I cannot get the controller class documentation comment info

@StingyJack
Copy link

What would an aspdotnet controller be equivalent to in an Open API Spec json? I dont think there is any place to put just the controller comments unless they were used as the beginning of each method's comments.

Do you have an example of what you would expect the result to look like?

@WeihanLi
Copy link
Author

WeihanLi commented Nov 28, 2022

image

There's a sample supported by Swashbuckle.AspNetCore
The swagger endpoint is https://reservation.weihanli.xyz/swagger/index.html

From the open API definition(https://reservation.weihanli.xyz/swagger/OpenReservation/swagger.json)
it seemed to be a tag

image

@StingyJack
Copy link

StingyJack commented Nov 28, 2022

Found this PR that sounds like it was supposed to add support for this. #2949

In the OpenApiDocumentGeneratorSettings add the property UseControllerSummaryAsTagDescription as true and see if that works. If it doesn't, then try setting breakpoints in this code and debugging

@WeihanLi
Copy link
Author

WeihanLi commented Nov 28, 2022

Works for me, thank you very much @StingyJack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants