swagger goes to api too

This commit is contained in:
Вячеслав 2025-04-21 04:28:38 +05:00
parent c89a87d73c
commit 8786549e51
2 changed files with 12 additions and 5 deletions

View file

@ -67,7 +67,10 @@ public class Program
};
});
builder.Services.AddControllers().AddJsonOptions(opts => { opts.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull; });
builder.Services.AddControllers().AddJsonOptions(opts =>
{
opts.JsonSerializerOptions.DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull;
});
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c =>
@ -101,8 +104,12 @@ public class Program
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
app.UseSwagger(options => { options.RouteTemplate = "api/swagger/{documentName}/swagger.json"; });
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/api/swagger/v1/swagger.json", "Survey Backend V1");
options.RoutePrefix = "api/swagger";
});
}
app.UseMiddleware<ExceptionsMiddleware>();

View file

@ -13,7 +13,7 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"launchUrl": "api/swagger",
"applicationUrl": "http://localhost:5231",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"