ASP.NET Core API with Swagger UI

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Tedds blog

Subscribe now to keep reading and get access to the full archive.

Continue reading