Reputation: 855
When I enable this documentation feature through Swagger I'm able to see all kind of information about my documentation but there is no details about my Controller name detail/description.
How to show controller documentation content like below example?
/// <summary>
/// Represents the alert api controller class.
/// <summary>
public class XYZController : ApiController
{
}
On enabling swagger I'm not able to see this content any where Represents the XYZ api controller class. here
However I able to see my all method description.
Upvotes: 33
Views: 42853
Reputation: 159
As some guys above have reply already, I guess the question was about this:
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
s.IncludeXmlComments(xmlPath, includeControllerXmlComments: true);
set includeControllerXmlComments: true
will allow to take summary of controllers.
Upvotes: 6
Reputation: 11
now, in .net core is easy
config.UseControllerSummaryAsTagDescription = true;
Upvotes: 1
Reputation: 642
1.) Right click the project and Edit projname.csproj Add the following
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
2.) Add the following to AddSwaggerGen in ConfigureServices
// Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
For more details goto:
Upvotes: 45
Reputation: 2247
in my case, I only needed to mark to use the XML document
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>C:...\CertReports.Host.xml</DocumentationFile>
Upvotes: 2
Reputation: 2337
This is possible, See @Liversage answer on this page https://github.com/domaindrivendev/Swashbuckle/issues/572
services.AddSwaggerGen(c =>
{
var xmlPath = ...;
c.IncludeXmlComments(xmlPath, includeControllerXmlComments: true);
});
Upvotes: 16
Reputation: 1765
you need to add IncludeXmlComments extension in AddSwaggerGen as below:
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1.0", new Info
{
Title = "My APIs",
Version = "v1.0",
Description = "REST APIs "
});
**// Set the comments path for the Swagger JSON and UI.**
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
Upvotes: 20
Reputation: 1114
I think this is related to the following issue : https://github.com/domaindrivendev/Swashbuckle/issues/572
It is currently not possible to display the controller summary, according to the maintainer:
The reason this has been low on the priority list is because it's not something I've run into issues with. You can absolutely describe what every action in your API does using XML comments on your actions.
Upvotes: 2
Reputation: 3634
Is there following code in the SwaggerConfig class?
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.IncludeXmlComments(string.Format(@"{0}\bin\YourAssemlyName.XML", System.AppDomain.CurrentDomain.BaseDirectory));
Upvotes: 5