Adding the Swagger UI to your application

Downloading the Swagger file and reading it can be a complex task for human beings. For us, it's much easier to see a visualization of the API in a nice, automatically generated UI, where we could easily see if the API is what we expect it to be.

Part of the Swashbuckle package you installed contains the Swagger UI, which is one of tools in the Swagger toolkit. To use it, add the following lines to the Configure method in the Startup class and specify the relative URL of the Swagger file in your API:

app.UseSwaggerUI(c =>{    c.SwaggerEndpoint("/swagger/v1/swagger.json", "GiveNTake.API");});

Run the application and browse to http://localhost:[port]/swagger. You should see a page similar to this:

Get Hands-On Full-Stack Web Development with ASP.NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.