Skip to content

Update samples to use Swagger / Swagger UI only in development environment.  #1024

@luisquintanilla

Description

@luisquintanilla

Update the code in the Web API sample projects to only use Swagger / Swagger UI when in the development environment.

Original

app.UseSwagger()
.UseSwaggerUI(c =>
{
c.SwaggerEndpoint($"{ (!string.IsNullOrEmpty(pathBase) ? pathBase : string.Empty) }/swagger/v1/swagger.json", "eShopDashboard.API V1");
});

Update code

https://github.com/dotnet/aspnetcore/blob/d594fc22076db3616a250817c3ca550fcbe69562/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.cs#L69-L73

if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions