This is a very simple activity
1. Add Swashbuckle.AspNetCore package from nuget.
2. Add following config in startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v2", new Microsoft.OpenApi.Models.OpenApiInfo
{
Title = "XXXX API",
Version = "1.0.0",
Description = "This is XXXX API",
});
});
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseHttpsRedirection();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
app.UseSwagger();
app.UseSwaggerUI(options => options.SwaggerEndpoint("/swagger/v2/swagger.json", "XXXX API"));
}
No comments:
Post a Comment