Class TypeSpecApiExtensions
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
servicesIServiceCollectiongeneratedContextJsonSerializerContext
Returns
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
servicesIServiceProviderhandlerTypesIReadOnlyList<Type>
Returns
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
appWebApplicationhandlerTypesIReadOnlyList<Type>