feat: first pass at theming swagger
this is a WIP, will return to this once we have endpoints on the swagger ui
This commit is contained in:
parent
21ad7f208a
commit
50122f8447
4 changed files with 159 additions and 2 deletions
27
Program.cs
27
Program.cs
|
@ -2,6 +2,7 @@ using System.Reflection;
|
|||
using Microsoft.OpenApi.Models;
|
||||
using ZenithInfo.Components;
|
||||
using ZenithInfo.Models;
|
||||
using ZenithInfo.Util.SwaggerTheme;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
@ -28,7 +29,15 @@ builder.Services.AddHttpLogging(o => { });
|
|||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen(opts =>
|
||||
{
|
||||
opts.SwaggerDoc("v1", new OpenApiInfo { Title = "Zenith Info API", Version = "v1" });
|
||||
opts.SwaggerDoc(
|
||||
"v1",
|
||||
new OpenApiInfo
|
||||
{
|
||||
Title = "Zenith Info API",
|
||||
Version = "v1",
|
||||
Description = "Zenith's official information provider!",
|
||||
}
|
||||
);
|
||||
opts.AddSecurityDefinition(
|
||||
"Bearer",
|
||||
new OpenApiSecurityScheme
|
||||
|
@ -66,10 +75,16 @@ builder.Services.AddSwaggerGen(opts =>
|
|||
|
||||
var app = builder.Build();
|
||||
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
foreach (var resource in assembly.GetManifestResourceNames())
|
||||
{
|
||||
app.Logger.LogDebug("Resource: {Resource}", resource);
|
||||
}
|
||||
|
||||
if (config?.UseSwagger == true)
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
app.UseSwaggerUI(CustomStyle.CustomModern);
|
||||
}
|
||||
|
||||
if (config?.LogRequests == true)
|
||||
|
@ -99,4 +114,12 @@ if (config?.DatabaseType == DatabaseTypes.Memory)
|
|||
);
|
||||
}
|
||||
|
||||
// if (app.Environment.IsDevelopment())
|
||||
// {
|
||||
// app.Logger.LogInformation(
|
||||
// "Development mode detected, printing configuration: {Configuration}",
|
||||
// config?.ToJson()
|
||||
// );
|
||||
// }
|
||||
|
||||
app.Run();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue