add swagger to web api .net core 3.1 code example
Example 1: integrate swagger in .net core api
Install-Package Swashbuckle.AspNetCore
using Microsoft.OpenApi.Models;
services.AddMvc();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "<title>", Version = "v1" });
});
app.UseSwagger();
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "<title> v1"));
"launchUrl": "swagger"
Example 2: swaggergen add service not getting info in .net core
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "The API", Version = "v1" });
});
Example 3: swaggergen add service not getting info in .net core
using Microsoft.OpenApi.Models;