5

I have a controller class (doesn't derive directly from ApiController) that has an XML comment:

/// <summary> /// The controller groups together all methods related to Trial Subscription Management. /// </summary> [RoutePrefix("api/v1")] public class TrialsController : TraceableApiController { ... } 

I can see the controller on the Swagger documentation page but the XML comment describing the controller is missing.

enter image description here

Is it possible to include the comment that describes the controller and if so, what do I have to do ?

4
  • Immediately after posting an answer I realised you wanted the controller comments. I've noticed this myself and don't have a solution either. Commented May 30, 2017 at 9:22
  • is the XML documentation just missing for this controller? Did you call IncludeXMLComments? Commented May 30, 2017 at 9:39
  • Comments (summary, remarks) is working just fine for methods defined inside the controller. Just the XML comments associated with the controller class itself never show up in the Swagger generated documentation. Commented May 30, 2017 at 9:57
  • Did you ever get a solution to this? Commented Apr 22, 2020 at 1:31

2 Answers 2

9

To get controller level comments to display in the SwaggerUI, you have to add a 2nd bool parameter = true to the IncludeXmlComments() method in .AddSwaggerGen(). Like this:

(.AddSwaggerGen() has been cut down for brevity)

 services.AddSwaggerGen(x => { //Locate the XML file being generated by ASP.NET... var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.XML"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); //... and tell Swagger to use those XML comments. x.IncludeXmlComments(xmlPath, includeControllerXmlComments: true); }); 

Reference: https://github.com/domaindrivendev/Swashbuckle/issues/1083#issuecomment-530471158

Sign up to request clarification or add additional context in comments.

Comments

0

I'm assuming you're using Swashbuckle to generate the Swagger docs. This is currently not a feature right now in Swashbuckle. It's being worked on at the time of writing.

https://github.com/domaindrivendev/Swashbuckle/pull/1087

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.