diff --git a/AdminHubApi/Program.cs b/AdminHubApi/Program.cs index 61554a2..9d01b77 100644 --- a/AdminHubApi/Program.cs +++ b/AdminHubApi/Program.cs @@ -21,6 +21,7 @@ builder.Services.AddSwaggerGen(option => { option.SwaggerDoc("v1", new OpenApiInfo { Title = "Admin Hub Api", Version = "v1" }); + option.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { In = ParameterLocation.Header, @@ -30,6 +31,7 @@ BearerFormat = "JWT", Scheme = "Bearer" }); + option.AddSecurityRequirement(new OpenApiSecurityRequirement { { @@ -37,11 +39,11 @@ { Reference = new OpenApiReference { - Type=ReferenceType.SecurityScheme, - Id="Bearer" + Type = ReferenceType.SecurityScheme, + Id = "Bearer" } }, - new string[]{} + new string[] { } } }); }); @@ -96,11 +98,27 @@ app.UseSwagger(); -// Configure the HTTP request pipeline. -if (app.Environment.IsDevelopment()) +app.UseSwaggerUI(options => { - app.UseSwaggerUI(); -} + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Web API V1"); + + if (app.Environment.IsDevelopment()) + { + options.RoutePrefix = "swagger"; + } + else + { + options.RoutePrefix = string.Empty; + } +}); + +app.UseSwagger(); + +// // Configure the HTTP request pipeline. +// if (app.Environment.IsDevelopment()) +// { +// app.UseSwaggerUI(); +// } app.UseHttpsRedirection();