Skip to content

Commit

Permalink
Call SwaggerUI only in dev env
Browse files Browse the repository at this point in the history
  • Loading branch information
tdykstra committed Apr 17, 2024
1 parent db641dd commit 37a0adb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
11 changes: 5 additions & 6 deletions 4-minimal-api/1-complete/PizzaStore/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "PizzaStore API V1");
});
}

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

app.MapGet("/", () => "Hello World!");

app.MapGet("/pizzas/{id}", (int id) => PizzaDB.GetPizza(id));
Expand Down
13 changes: 6 additions & 7 deletions 4-minimal-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,14 @@ Use Swagger to ensure that you have a self-documenting API, where the docs chang
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "PizzaStore API V1");
});
}
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "PizzaStore API V1");
});
app.MapGet("/", () => "Hello World!");
app.Run();
Expand Down

0 comments on commit 37a0adb

Please sign in to comment.