For my .net core 8.0 api project, I'm using Swashbuckle.AspNetCore 6.5.0 to .AddSwaggerGen() which generates and serves the a .json file at http://localhost:5229/swagger/my_api_name/swagger.json that I can browse at http://localhost:5229/swagger/index.html.
I want to inlcude the controller action ///<summary> comment as a summary under the end point.
However, the only way that I can see in the Swashbuckle Github repo is to include controller xmldocs is using
public static void IncludeXmlComments(
this SwaggerGenOptions swaggerGenOptions,
string filePath,
bool includeControllerXmlComments = false)
I don't want to generate an XML file, how can I include the xmldoc comments in the .json file being generated?
I want to include the controller action
///<summary>comment as a summary under the end point.This isn't possible without use of the Xml Document generated by the c# compiler.
Get started with Swashbuckle and ASP.NET Core
From the above, You will have to use the c# compiler to generate the xml documentation file (In order for
Swashbuckleto pick up your endpoint descriptions in the<summary>element from the generated xml document) which is a painless process.Simply enable GenerateDocumentationFile in your
.csprojand configure Swagger to read the generated file.