Skip to content

Commit a0ccfc8

Browse files
authored
Merge pull request #50 from tdykstra/swaggeruiindev
Call SwaggerUI only in dev env
2 parents db641dd + a32355f commit a0ccfc8

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

4-minimal-api/1-complete/PizzaStore/Program.cs

+5-6
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
if (app.Environment.IsDevelopment())
1515
{
1616
app.UseDeveloperExceptionPage();
17+
app.UseSwagger();
18+
app.UseSwaggerUI(c =>
19+
{
20+
c.SwaggerEndpoint("/swagger/v1/swagger.json", "PizzaStore API V1");
21+
});
1722
}
1823

19-
app.UseSwagger();
20-
app.UseSwaggerUI(c =>
21-
{
22-
c.SwaggerEndpoint("/swagger/v1/swagger.json", "PizzaStore API V1");
23-
});
24-
2524
app.MapGet("/", () => "Hello World!");
2625

2726
app.MapGet("/pizzas/{id}", (int id) => PizzaDB.GetPizza(id));

4-minimal-api/README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,13 @@ Use Swagger to ensure that you have a self-documenting API, where the docs chang
112112
if (app.Environment.IsDevelopment())
113113
{
114114
app.UseDeveloperExceptionPage();
115+
app.UseSwagger();
116+
app.UseSwaggerUI(c =>
117+
{
118+
c.SwaggerEndpoint("/swagger/v1/swagger.json", "PizzaStore API V1");
119+
});
115120
}
116-
117-
app.UseSwagger();
118-
app.UseSwaggerUI(c =>
119-
{
120-
c.SwaggerEndpoint("/swagger/v1/swagger.json", "PizzaStore API V1");
121-
});
122-
121+
123122
app.MapGet("/", () => "Hello World!");
124123
125124
app.Run();

0 commit comments

Comments
 (0)