using Microsoft.AspNetCore.Builder; using Microsoft.OpenApi; using System.Reflection; var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(); builder.Services.AddOpenApi(); builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen(options => { options.SwaggerDoc("v1", new OpenApiInfo { Version = "v1", Title = "Shadow API", Description = "An ASP.NET Core Web music API compatible with a subset of Subsonic endpoints", Contact = new OpenApiContact { Name = "Shadow's production branch", Url = new Uri("https://shadow.7o7.cx") }, License = new OpenApiLicense { Name = "AGPLv3", Url = new Uri("https://www.gnu.org/licenses/agpl-3.0.en.html") } }); //// https://stackoverflow.com/a/58972781 //options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme //{ // Description = @"JWT Authorization header using the Bearer scheme.
// Enter your JWT from /api/v1/auth/login to authorize.", // Name = "Authorization", // In = ParameterLocation.Header, // Type = SecuritySchemeType.Http, // Scheme = "Bearer" //}); //options.AddSecurityRequirement((document) => new OpenApiSecurityRequirement() //{ // [new OpenApiSecuritySchemeReference("bearer", document)] = [] //}); // using System.Reflection; var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; options.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename)); }); var app = builder.Build(); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.MapOpenApi(); app.UseSwagger(); app.UseSwaggerUI(); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();