From 8786549e51df4506fd42b164dc79a03027be5fb0 Mon Sep 17 00:00:00 2001 From: shept Date: Mon, 21 Apr 2025 04:28:38 +0500 Subject: [PATCH] swagger goes to api too --- SurveyBackend/SurveyBackend.API/Program.cs | 15 +++++++++++---- .../Properties/launchSettings.json | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/SurveyBackend/SurveyBackend.API/Program.cs b/SurveyBackend/SurveyBackend.API/Program.cs index 7c22f06..4c1f57b 100644 --- a/SurveyBackend/SurveyBackend.API/Program.cs +++ b/SurveyBackend/SurveyBackend.API/Program.cs @@ -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.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(); diff --git a/SurveyBackend/SurveyBackend.API/Properties/launchSettings.json b/SurveyBackend/SurveyBackend.API/Properties/launchSettings.json index 589b161..6198e4a 100644 --- a/SurveyBackend/SurveyBackend.API/Properties/launchSettings.json +++ b/SurveyBackend/SurveyBackend.API/Properties/launchSettings.json @@ -13,7 +13,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "launchUrl": "swagger", + "launchUrl": "api/swagger", "applicationUrl": "http://localhost:5231", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development"