RESTful Api Endpoints
How often have you been in a situation where you’re having to code against an undocumented API? Perhaps your team is building an API and publishing it to another group of developers. Understanding the API endpoints without the correct documentation can be a challenge…
Swagger enables you o generate interactive documentation as a readable representation of a RESTful API.
In order to generate Swagger documents for our C# ASP.Net Core Web Api application, we need to utilise Swashbuckle - An open source project.
I’ve implemented a basic C# ASP.Net Core Web Api solution with 2 public endpoints for us to document.
Now to pull in the required Swashbuckle packages from Nuget.
Now to add our configuration into the appsettings file.
Head to your Startup.cs file and let’s configure our Swagger middleware. Our previously added configuration details can now be made use of.
Now to make use of the variables and configure our Swagger service.
We can now configure our Swagger endpoint.
Finally let’s head to the endpoint URL -
…and here’s the result!