Skip to content

Getting started with Swashbuckle on ASP.NET Core

Jonathan edited this page Jan 14, 2020 · 6 revisions

At a minimum, you'll need the following to get started...

Within the project file:

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0" />
  </ItemGroup>

Within Startup.cs:

In public void ConfigureServices(IServiceCollection services):

    services.AddSwaggerGen(c =>
    {
        c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
    });

In public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory):

    app.UseSwagger();
    app.UseSwaggerUI(c =>
    {
        c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
    });

fa

Clone this wiki locally