Skip to content

Commit

Permalink
Merge pull request #50 from tdykstra/swaggeruiindev
Browse files Browse the repository at this point in the history
Call SwaggerUI only in dev env
  • Loading branch information
jongalloway authored Apr 22, 2024
2 parents db641dd + a32355f commit a0ccfc8
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 @@ -112,14 +112,13 @@ Use Swagger to ensure that you have a self-documenting API, where the docs chang
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.Run();
Expand Down

0 comments on commit a0ccfc8

Please sign in to comment.