Documenting ASP.NET Core 2.0 Web API


How to add documentation and help pages for ASP.NET Core Web API.


Add NuGet package: Swashbuckle.AspNetCore

Update Startup to add services and middleware for Swagger:

The help page can be accessed via: [host]/swagger


Swagger is a format to describe RESTful APIs and Swashbuckle generate these swagger documents.

Note: the name specified when configuring services via SwaggerDoc method (e.g. “help” our sample code) must be same as the specified in SwaggerEndpoint method.

XML Documentation

Documents generated by Swagger can include XML documentation. This can be turned on from project Properties > Build tab and configuring swagger services:

Using XML comments, data annotations on model and action attributes we can produce detailed documentation that would be useful for the client developers, e.g.:

Source Code


Leave a Reply