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

How do you specify controller descriptions? #1803

Open
drullo opened this issue Dec 6, 2018 · 11 comments
Open

How do you specify controller descriptions? #1803

drullo opened this issue Dec 6, 2018 · 11 comments

Comments

@drullo
Copy link

drullo commented Dec 6, 2018

I have a .NET Core web API written in C# and I have been unable to get NSwag to include descriptions for the controllers. I have tried a DescriptionAttribute and a standard <summary> comment. My actions and parameters are being properly documented, including description (summary) and remarks.

Also, I see from the documentation that there's a recommendation to set IsAspNetCore to true. Where/how do you set that value and is it a current requirement? I'm not sure what the implications are of the "reflection based generator eventually being deprecated" - does that mean that I need to change my approach to controller documentation somehow?

@RicoSuter
Copy link
Owner

You should integrate with the middleware and use the api explorer based generator for asp.net core

@RicoSuter
Copy link
Owner

You need to enable xml docs output in the project...

@drullo
Copy link
Author

drullo commented Dec 6, 2018

@RSuter , I do have xml doc output enabled in the project. Without it, I wasn't getting any summary/parameter documentation at all. It is enabled and it is working for controller actions. But what I'm lacking are descriptions on the actual controllers themselves.

For clarification of what I'm looking for, the demo at http://petstore.swagger.io includes descriptions on each of the 3 controllers, as well as additional information displayed on the right.

@RicoSuter
Copy link
Owner

RicoSuter commented Dec 12, 2018

I think this might be a bug

@RicoSuter
Copy link
Owner

But what I'm lacking are descriptions on the actual controllers themselves.

The controller descriptions cannot be preserved because "controllers" is not a concept of Swagger and only internally generated/grouped by NSwag... We'd need to enhance the spec with custom data with controller info etc.

@BlackfinchGroup
Copy link

Guessing this feature isn't being added anytime soon?

@RicoSuter
Copy link
Owner

Probably not, as custom extensions do not bring much value as they are not understood by consumers (external client gens, etc.)

But you can do this manually with custom operation processors: https://github.com/RicoSuter/NSwag/wiki/Document-Processors-and-Operation-Processors

@BlackfinchGroup
Copy link

Could not controllers be mapped to the tags concept in swagger.
For example in the petstore yaml - https://petstore.swagger.io/ - this creates grouped endpoints, similar in concept to controllers.

tags:
- name: "pet"
  description: "Everything about your Pets"
paths:
  /pet:
    post:
      tags:
      - "pet"

@RicoSuter
Copy link
Owner

I think this is already the case except that the description is not used, can you create a PR?

@tux1337
Copy link

tux1337 commented Mar 11, 2022

I tested it these times, and it is still not working with the <summary> tag. Do I'm something wrong or is still an PR needed?

@SmRiley
Copy link

SmRiley commented Aug 15, 2023

now,u can use that enable controller description:

services.AddSwaggerDocument(c =>
  {
      c.UseControllerSummaryAsTagDescription = true;
  });

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

No branches or pull requests

4 participants