8000 Add `IsDevelopment` guard to UseSwaggerUI in samples (#1030) · dotnet/machinelearning-samples@af0ced0 · GitHub
[go: up one dir, main page]

Skip to content

Commit af0ced0

Browse files
authored
Add IsDevelopment guard to UseSwaggerUI in samples (#1030)
* Add `IsDevelopment` guard to UseSwaggerUI in samples * Update Program.cs * Update Program.cs * Fix eShopDashboard sample
1 parent 6b28e25 commit af0ced0

File tree

2 files changed

+9
-6
lines changed
  • samples
    • csharp/end-to-end-apps/Forecasting-Sales/src/eShopDashboard
    • modelbuilder/ImageClassification_Azure_LandUse/LandUse_WebApi

2 files changed

+9
-6
lines changed

samples/csharp/end-to-end-apps/Forecasting-Sales/src/eShopDashboard/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
9595
var pathBase = Configuration["PATH_BASE"];
9696

9797
app.UseSwagger();
98-
if (app.Environment.IsDevelopment())
98+
if (env.IsDevelopment())
9999
{
100100
app.UseSwaggerUI(c =>
101101
{

samples/modelbuilder/ImageClassification_Azure_LandUse/LandUse_WebApi/Program.cs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line c 8000 hange
@@ -1,5 +1,6 @@
1-
// This file was auto-generated by ML.NET Model Builder.
1+
// This file was auto-generated by ML.NET Model Builder.
22
using Microsoft.AspNetCore.Builder;
3+
using Microsoft.Extensions.Hosting;
34
using Microsoft.Extensions.DependencyInjection;
45
using Microsoft.Extensions.ML;
56
using Microsoft.OpenApi.Models;
@@ -20,10 +21,13 @@
2021

2122
app.UseSwagger();
2223

23-
app.UseSwaggerUI(c =>
24+
if (app.Environment.IsDevelopment())
2425
{
25-
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
26-
});
26+
app.UseSwaggerUI(c =>
27+
{
28+
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
29+
});
30+
}
2731

2832
// Define prediction route & handler
2933
app.MapPost("/predict",
@@ -32,4 +36,3 @@
3236

3337
// Run app
3438
app.Run();
35-

0 commit comments

Comments
 (0)
0