Files
NTBug/backend/src/Helpdesk.Api/Infrastructure/SwaggerSetup.cs
T
PatTheEvil a51d386278 Základní backend: migrace, autentizace JWT, role, Swagger
- Helpdesk.Migrator (DbUp) aplikuje db/migrations, evidence v schema_version
- Domain/Application/Infrastructure/Api podle Clean Architecture
- registrace, ověření e-mailu, login, refresh s rotací, logout, reset hesla
- JWT podle RFC 7519 evidované jen podle jti v auth_token
- správa uživatelů a rolí, číselníky, ProblemDetails, Swagger UI
- Docker Compose (db, migrator, api), oddělené DB účty
- notifikace mají cizí klíče na issue a proposal
- unit testy domény a zabezpečení

Closes #1, closes #2, closes #3, closes #4, closes #5, closes #9
2026-10-28 21:43:17 +01:00

41 lines
1.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Microsoft.OpenApi;
namespace Helpdesk.Api.Infrastructure;
public static class SwaggerSetup
{
private const string SchemeId = "Bearer";
/// <summary>Swagger UI na <c>/swagger</c> včetně přihlášení access tokenem (NFR-04).</summary>
public static IServiceCollection AddHelpdeskSwagger(this IServiceCollection services)
{
services.AddEndpointsApiExplorer();
services.AddSwaggerGen(options =>
{
options.SwaggerDoc("v1", new OpenApiInfo
{
Title = "Univerzitní helpdesk – API",
Version = "v1",
Description = "REST API pro webovou a mobilní aplikaci. Access token získáte přes POST /api/auth/login.",
});
options.AddSecurityDefinition(SchemeId, new OpenApiSecurityScheme
{
Type = SecuritySchemeType.Http,
Scheme = "bearer",
BearerFormat = "JWT",
Description = "Vložte access token (bez předpony „Bearer“).",
});
options.AddSecurityRequirement(document => new OpenApiSecurityRequirement
{
[new OpenApiSecuritySchemeReference(SchemeId, document)] = [],
});
var xml = Path.Combine(AppContext.BaseDirectory, "Helpdesk.Api.xml");
if (File.Exists(xml))
options.IncludeXmlComments(xml);
});
return services;
}
}