ASP.NET Core API with Swagger UI

By | 2019-06-20

Swagger makes the API machine readable. This means documentation and client implementations can be produced automatically. Swashbuckle runs top of Swagger and provides an UI. Together they provide nice functionality for documenting and testing your API.

Install

Implement

In Startup.cs ConfigureServices:

In Configure:

RoutePrefix is required when API is located under /api/.

Note that Swagger is sensitive to errors in Controller, i.e. missing [HttpGet] or similar. You can get a hint of what is wrong by visiting /swagger/v1/swagger.json.

Test

Navigate to /api/-folder of website.

Leave a Reply

Your email address will not be published. Required fields are marked *