Let us take the previous example itself.,
Please refer :
https://dotnetbyudayrajakonda.blogspot.com/2023/10/creating-basic-aspnet-web-api.html
First, we need to install a package called
Swashbuckle via NuGet as shown below.
You can install NuGet packages in two ways one using command and the other using manage Nuget package from project window
Swagger with XML Comments
Now, In the Solution Explorer right-click on the Web API project and click on the Properties. Click the Build tab and navigate to Output. Make sure the XML documentation file is checked. You can leave the default file path. In our case its bin\FirstWebAPIDemo.XML as shown below
Next, goto SwaggerConfig.cs and make the below changes
{
public static void Register()
{
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "First WEB Swagger Demo");
c.IncludeXmlComments(string.Format(@"{0}\bin\WebApplication1.XML",
System.AppDomain.CurrentDomain.BaseDirectory));
})
.EnableSwaggerUi();
}
}
Now, goto ValuesController and add some xml comments to it as shown below
No comments:
Post a Comment
Thank you for visiting my blog