Cleanup and more fixes
This commit is contained in:
@@ -4,6 +4,8 @@ using Hutopy.Infrastructure.Data;
|
||||
using Hutopy.Web;
|
||||
using Azure.Identity;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
using NSwag;
|
||||
using NSwag.Generation.Processors.Security;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@@ -48,6 +50,25 @@ builder.Services.AddWebServices();
|
||||
builder.Services.AddAuthorizationAndAuthentication(builder.Configuration);
|
||||
builder.Services.AddControllers();
|
||||
|
||||
builder.Services.AddOpenApiDocument((configure, sp) =>
|
||||
{
|
||||
configure.Title = "Hutopy API";
|
||||
|
||||
// Add JWT
|
||||
configure.AddSecurity(
|
||||
"JWT",
|
||||
[],
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Type = OpenApiSecuritySchemeType.ApiKey,
|
||||
Name = "Authorization",
|
||||
In = OpenApiSecurityApiKeyLocation.Header,
|
||||
Description = "Type into the textbox: Bearer {your JWT token}."
|
||||
});
|
||||
|
||||
configure.OperationProcessors.Add(new AspNetCoreOperationSecurityScopeProcessor("JWT"));
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseForwardedHeaders(
|
||||
@@ -75,22 +96,18 @@ app.UseHealthChecks("/health");
|
||||
app.UseHttpsRedirection();
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseSwaggerUi(settings =>
|
||||
if (app.Environment.IsDevelopment())
|
||||
{
|
||||
settings.Path = "/api";
|
||||
settings.DocumentPath = "/api/specification.json";
|
||||
});
|
||||
app.UseOpenApi();
|
||||
app.UseSwaggerUi(options => options.Path = "/api");
|
||||
}
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller}/{action=Index}/{id?}");
|
||||
|
||||
app.MapFallbackToFile("index.html");
|
||||
|
||||
app.UseExceptionHandler(options => { });
|
||||
|
||||
app.Map("/", () => Results.Redirect("/api"));
|
||||
|
||||
//TODO: validate the behavior
|
||||
// app.UseExceptionHandler();
|
||||
app.MapEndpoints();
|
||||
|
||||
app.Run();
|
||||
|
||||
Reference in New Issue
Block a user