RazorDocs Search

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.

📂 Back to Web List | 🏠 Back to Root

Type

RunnableWebOpenApiModule

A web module that integrates OpenAPI/Swagger document generation into the application.

Method

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.
Method

ConfigureEndpoints

void ConfigureEndpoints(StartupContext context, IEndpointRouteBuilder endpoints)

Maps the OpenAPI document endpoint.

Parameters

  • contextThe startup context.
  • endpointsThe endpoint route builder.
Method

RegisterDependentModules

void RegisterDependentModules(ModuleDependencyBuilder builder)

Registers dependencies for this module; currently no implementation is required.

Parameters

  • builderThe module dependency builder.
Method

ConfigureHostBeforeServices

void ConfigureHostBeforeServices(StartupContext context, IHostBuilder builder)

Executes pre-service host configuration; currently no implementation is required.

Parameters

  • contextThe startup context.
  • builderThe host builder.
Method

ConfigureHostAfterServices

void ConfigureHostAfterServices(StartupContext context, IHostBuilder builder)

Executes post-service host configuration; currently no implementation is required.

Parameters

  • contextThe startup context.
  • builderThe host builder.
Method

ConfigureWebApplication

void ConfigureWebApplication(StartupContext context, IApplicationBuilder app)

Configures the web application pipeline; currently no implementation is required.

Parameters

  • contextThe startup context.
  • appThe application builder.