update swagger implementation

This commit is contained in:
voltsrage
2026-06-26 04:22:47 +08:00
parent 869006e5e7
commit 9777a335c5
8 changed files with 126 additions and 36 deletions
@@ -0,0 +1,51 @@
using System.Reflection;
using Microsoft.OpenApi.Models;
public static class SwaggerServiceCollectionExtensions
{
public static IServiceCollection AddVigilCareRecordsSwagger(this IServiceCollection services)
{
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Title = "VigilCare Records API",
Version = "v1",
Description = "Digitization workflow API for scanned chart intake, verification, and promotion."
});
options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Name = "Authorization",
Type = SecuritySchemeType.Http,
Scheme = "bearer",
BearerFormat = "JWT",
In = ParameterLocation.Header,
Description = "JWT obtained from POST /api/v1/auth/login"
});
options.AddSecurityRequirement(new OpenApiSecurityRequirement
{
{
new OpenApiSecurityScheme
{
Reference = new OpenApiReference
{
Type = ReferenceType.SecurityScheme,
Id = "Bearer"
}
},
Array.Empty<string>()
}
});
var xmlPath = Path.Combine(
AppContext.BaseDirectory,
$"{Assembly.GetExecutingAssembly().GetName().Name}.xml");
if (File.Exists(xmlPath))
options.IncludeXmlComments(xmlPath);
});
return services;
}
}