OpenApi
ForgeTrust.Runnable.Web.OpenApi
This package provides a modular integration for OpenAPI (Swagger) document generation in Runnable web applications.
Overview
The RunnableWebOpenApiModule simplifies the configuration of OpenAPI by:
- Registering the necessary services via
AddOpenApi. - Configuring the
EndpointsApiExplorer. - Automatically mapping the OpenAPI documentation endpoints.
- Providing default document and operation transformers to clean up and brand the generated documentation based on the
StartupContext.
Usage
To enable OpenAPI support in your application, add the RunnableWebOpenApiModule as a dependency in your root module:
public class MyModule : IRunnableWebModule
{
public void RegisterDependentModules(ModuleDependencyBuilder builder)
{
builder.AddModule<RunnableWebOpenApiModule>();
}
// ...
}
Features
- Document Transformation: Automatically updates the API title and tags based on the application name defined in the
StartupContext. - Automatic Endpoint Mapping: Calls
endpoints.MapOpenApi()for you during the endpoint configuration phase.
RunnableWebOpenApiModule
A web module that integrates OpenAPI/Swagger document generation into the application.
ConfigureServices
void ConfigureServices(StartupContext context, IServiceCollection services)
Configures services needed for OpenAPI, including document and operation transformers to customize the generated schema.
Parameters
contextThe startup context.servicesThe service collection to populate.
ConfigureEndpoints
void ConfigureEndpoints(StartupContext context, IEndpointRouteBuilder endpoints)
Maps the OpenAPI document endpoint.
Parameters
contextThe startup context.endpointsThe endpoint route builder.
RegisterDependentModules
void RegisterDependentModules(ModuleDependencyBuilder builder)
Registers dependencies for this module; currently no implementation is required.
Parameters
builderThe module dependency builder.
ConfigureHostBeforeServices
void ConfigureHostBeforeServices(StartupContext context, IHostBuilder builder)
Executes pre-service host configuration; currently no implementation is required.
Parameters
contextThe startup context.builderThe host builder.
ConfigureHostAfterServices
void ConfigureHostAfterServices(StartupContext context, IHostBuilder builder)
Executes post-service host configuration; currently no implementation is required.
Parameters
contextThe startup context.builderThe host builder.
ConfigureWebApplication
void ConfigureWebApplication(StartupContext context, IApplicationBuilder app)
Configures the web application pipeline; currently no implementation is required.
Parameters
contextThe startup context.appThe application builder.