Table of Contents

Class ControllersRegistration

Namespace
Tharga.Team.Service
Assembly
Tharga.Team.Service.dll

Extension methods for registering API controllers with OpenAPI and Swagger.

public static class ControllersRegistration
Inheritance
ControllersRegistration
Inherited Members

Methods

AddThargaApiKeys(IServiceCollection)

Registers the default API key storage, administration service, and hashing service. Also registers the MongoDB repository types explicitly so they are available regardless of the entry assembly name prefix used by the consumer.

public static IServiceCollection AddThargaApiKeys(this IServiceCollection services)

Parameters

services IServiceCollection

Returns

IServiceCollection

AddThargaControllers(IServiceCollection, Action<ThargaControllerOptions>)

Registers MVC controllers, OpenAPI document with API key security scheme, Swagger, and endpoints API explorer.

public static IServiceCollection AddThargaControllers(this IServiceCollection services, Action<ThargaControllerOptions> configure = null)

Parameters

services IServiceCollection
configure Action<ThargaControllerOptions>

Returns

IServiceCollection

UseThargaControllers(WebApplication)

Maps controllers, OpenAPI endpoint, and Swagger UI, and resolves the team a request acts on.

public static WebApplication UseThargaControllers(this WebApplication app)

Parameters

app WebApplication

Returns

WebApplication

Remarks

Call this after UseAuthorization(). An API key is authenticated by the policy that names its scheme, and that happens during authorization — so the team-context middleware placed before it would see an unauthenticated caller and silently do nothing, leaving the header ignored rather than refused. Found by an end-to-end test; no unit test of the middleware could show it, because the ordering is the whole defect.