Table of Contents

Class TypeSpecApiExtensions

Namespace
Olve.TypeSpec
Assembly
Olve.TypeSpec.dll

Wires a generated API surface into the app. The generated code calls these from its own Add…Api / Use…Api, passing what only it knows: its JSON context and handler types.

public static class TypeSpecApiExtensions
Inheritance
TypeSpecApiExtensions
Inherited Members

Methods

AddTypeSpecApi(IServiceCollection, JsonSerializerContext)

Registers the generated JSON source-gen context and makes binding failures throw, so BindingFailureMiddleware can answer them. The app registers its own IApiErrorWriter.

public static IServiceCollection AddTypeSpecApi(this IServiceCollection services, JsonSerializerContext generatedContext)

Parameters

services IServiceCollection
generatedContext JsonSerializerContext

Returns

IServiceCollection

MissingHandlers(IServiceProvider, IReadOnlyList<Type>)

The handler interfaces among handlerTypes that have no registered implementation.

public static IReadOnlyList<Type> MissingHandlers(this IServiceProvider services, IReadOnlyList<Type> handlerTypes)

Parameters

services IServiceProvider
handlerTypes IReadOnlyList<Type>

Returns

IReadOnlyList<Type>

UseTypeSpecApi(WebApplication, IReadOnlyList<Type>)

Checks every operation's handler and the IApiErrorWriter are registered, then adds the binding-failure middleware. Fails fast, so a new operation in the spec can't ship as a runtime 500. The generated Map…Api maps the routes afterwards.

public static WebApplication UseTypeSpecApi(this WebApplication app, IReadOnlyList<Type> handlerTypes)

Parameters

app WebApplication
handlerTypes IReadOnlyList<Type>

Returns

WebApplication