Wednesday 29 May 2019

how to add swagger in aspnetcore

follow the steps

type in searchbox : swashbuckle.aspnetcore
add this dll

now go to startup.cs file and add the code in ConfigureServices methosd

 public void ConfigureServices(IServiceCollection services)
        {
         
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info { Title = "Employees Api", Version = "v1" });
            }
                );
           
        }

then in last inside the configure method write line of code
app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Employee Api V1");
            }
                );

then finally run your app

and type just like:
http://localhost:60855/swagger/

No comments:

Post a Comment