I have configured Swagger in my .NET 6 Web API project. In local, I can access Swagger file. Below is my code for that.
public static void ConfigureSwaggerMiddleware(this WebApplication app)
{
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.yaml", "API V1");
});
}
else
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("swagger/v1/swagger.yaml", "API V1");
c.RoutePrefix = "api/abc";
});
}
}
Now, I want to configure its URL in dev, test and higher environment like https://devurl/api/abc/swagger.yaml. I am trying above code but I am getting an error as
No webpage was found for the web address: https://localhost:7120/swagger/index.html