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,8 +67,11 @@ 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.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen(c => builder.Services.AddSwaggerGen(c =>
{ {
@ -101,8 +104,12 @@ public class Program
if (app.Environment.IsDevelopment()) if (app.Environment.IsDevelopment())
{ {
app.UseSwagger(); app.UseSwagger(options => { options.RouteTemplate = "api/swagger/{documentName}/swagger.json"; });
app.UseSwaggerUI(); app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/api/swagger/v1/swagger.json", "Survey Backend V1");
options.RoutePrefix = "api/swagger";
});
} }
app.UseMiddleware<ExceptionsMiddleware>(); app.UseMiddleware<ExceptionsMiddleware>();

View file

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