From a32355f7e52d17325b88d097908614523af15dd0 Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Sun, 21 Apr 2024 07:07:01 -0700 Subject: [PATCH] call swaggerui only in dev env --- 4-minimal-api/1-complete/PizzaStore/Program.cs | 11 +++++------ 4-minimal-api/README.md | 13 ++++++------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/4-minimal-api/1-complete/PizzaStore/Program.cs b/4-minimal-api/1-complete/PizzaStore/Program.cs index 8841f9f..12f08d8 100644 --- a/4-minimal-api/1-complete/PizzaStore/Program.cs +++ b/4-minimal-api/1-complete/PizzaStore/Program.cs @@ -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)); diff --git a/4-minimal-api/README.md b/4-minimal-api/README.md index c9c2d5e..a70102c 100644 --- a/4-minimal-api/README.md +++ b/4-minimal-api/README.md @@ -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();