dotnet / machinelearning-samples

Samples for ML.NET, an open source and cross-platform machine learning framework for .NET.
https://dot.net/ml
MIT License
4.47k stars 2.68k forks source link

Update samples to use Swagger / Swagger UI only in development environment. #1024

Closed luisquintanilla closed 5 months ago

luisquintanilla commented 5 months ago

Update the code in the Web API sample projects to only use Swagger / Swagger UI when in the development environment.

Original

https://github.com/dotnet/machinelearning-samples/blob/a262b189468bc0ac13acbc405a08e213d1f88bb5/samples/csharp/end-to-end-apps/Forecasting-Sales/src/eShopDashboard/Startup.cs#L97-L101

Update code

https://github.com/dotnet/aspnetcore/blob/d594fc22076db3616a250817c3ca550fcbe69562/src/ProjectTemplates/Web.ProjectTemplates/content/WebApi-CSharp/Program.cs#L69-L73

if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}