services.AddSwaggerGen(c =>
{
// Set Title and version from config
c.SwaggerDoc("v1", new Info { Title = "My Title", Version = "1.0", Description = "My Description" });
// Set the comments path for the Swagger JSON and UI.
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
// pick comments from classes, include controller comments: another tip from StackOverflow
c.IncludeXmlComments(xmlPath, includeControllerXmlComments: true);
// enable the annotations on Controller classes [SwaggerTag]
c.EnableAnnotations();
// to allow for a header parameter
c.OperationFilter<AddRequiredHeaderParameter>();
});
Update for Swashbuckle 4.x, which does support the use of the tag. (see https://github.com/domaindrivendev/Swashbuckle.AspNetCore )
Update for Swashbuckle 4.x, which does support the use of the tag. (see https://github.com/domaindrivendev/Swashbuckle.AspNetCore )