Koalesce.OpenAPI 1.0.0-alpha.12

Suggested Alternatives

Koalesce

Additional Details

Koalesce.OpenAPI was renamed to Koalesce

This is a prerelease version of Koalesce.OpenAPI.
dotnet add package Koalesce.OpenAPI --version 1.0.0-alpha.12
                    
NuGet\Install-Package Koalesce.OpenAPI -Version 1.0.0-alpha.12
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Koalesce.OpenAPI" Version="1.0.0-alpha.12" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Koalesce.OpenAPI" Version="1.0.0-alpha.12" />
                    
Directory.Packages.props
<PackageReference Include="Koalesce.OpenAPI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Koalesce.OpenAPI --version 1.0.0-alpha.12
                    
#r "nuget: Koalesce.OpenAPI, 1.0.0-alpha.12"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Koalesce.OpenAPI@1.0.0-alpha.12
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Koalesce.OpenAPI&version=1.0.0-alpha.12&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Koalesce.OpenAPI&version=1.0.0-alpha.12&prerelease
                    
Install as a Cake Tool

Koalesce

Koalesce

Koalesce is an open-source, lightweight and extensible library designed to merge multiple API definitions into a unified document.

Official packages are published exclusively to NuGet.org by the maintainer. Do not trust packages from unofficial sources.


How It Works

  • Koalesce fetches API definitions from the specified Sources.
  • It merges them using an available provider (e.g., Koalesce.OpenAPI), generating a single schema at MergedDocumentPath.
  • The final Koalesced API definition is serialized and available in JSON or YAML format.

Key Features

  • Merge Multiple APIs: Coalesce multiple API definitions into one unified schema.
  • Conflict Resolution: Automatic schema renaming and path collision detection.
  • Flexible Configuration: Configure via appsettings.json or Fluent API.
  • Fail-Fast Validation: Validates URLs and paths at startup to prevent runtime errors.
  • Gateway Integration: Works seamlessly with Ocelot, YARP, and other API Gateways.
  • Configurable Caching: Fine-grained cache control with absolute/sliding expiration settings.
  • Ease Client Generation: Streamlines API client generation (e.g., NSwag, Kiota) with a single unified schema.
  • Format Agnostic Output: Output JSON or YAML regardless of source document format.
  • Extensible Core: Designed to support future providers for other API specification formats.

Design Philosophy

Koalesce balances Developer Experience with architectural governance:

  • Resilient by Default: If a microservice is down, Koalesce skips it without breaking your Gateway.
  • Strict by Choice: Can be configured to fail on unreachable services or route collisions - useful for CI/CD pipelines.
  • Purposefully Opinionated: Ensures merged definitions have clean, deterministic, and conflict-free naming.

Where Koalesce Shines

Koalesce is ideal for Backend-for-Frontend (BFF) patterns where external consumers need a unified API view.

  • Frontend applications consuming an API Gateway.
  • SDK generation with tools like NSwag/Kiota from a single unified schema.
  • Third-party developer portals exposing your APIs.
  • External API consumers needing consolidated documentation.

Quick Start

1. Register Koalesce

builder.Services.AddKoalesce(builder.Configuration)
    .ForOpenAPI();

2. Enable Middleware

app.UseKoalesce();

Configuration

Core Configuration (Koalesce)

Setting Type Default Description
Sources array required List of API sources with Url, optional VirtualPrefix, and optional ExcludePaths
MergedDocumentPath string required Path where the merged API definition is exposed
Title string "My Koalesced API" Title for the merged API definition
SkipIdenticalPaths boolean true If false, throws exception on duplicate paths
SchemaConflictPattern string "{Prefix}_{SchemaName}" Pattern for resolving schema name conflicts
FailOnServiceLoadError boolean false If true, aborts startup if ANY source is unreachable

Source Configuration

Setting Type Default Description
Url string required URL of the API definition (must be absolute URL)
VirtualPrefix string null Optional prefix to apply to routes (e.g., /inventory)
ExcludePaths array null Optional list of paths to exclude. Supports wildcards (e.g., "/api/admin/*")

Caching Configuration

Setting Type Default Description
DisableCache boolean false If true, recomputes the merged document on every request
AbsoluteExpirationSeconds integer 86400 (24h) Max duration before a forced refresh
SlidingExpirationSeconds integer 300 (5 min) Resets expiration on every access
MinExpirationSeconds integer 30 Minimum allowed expiration time

OpenAPI Provider Configuration

Setting Type Default Description
OpenApiVersion string "3.0.1" Target OpenAPI version for the output
ApiGatewayBaseUrl string null The public URL of your Gateway. Activates Gateway Mode

Configuration Examples

Aggregation Mode

{
  "Koalesce": {
    "Sources": [
      { "Url": "https://service1.com/swagger.json" },
      { "Url": "https://service2.com/swagger.json" }
    ],
    "MergedDocumentPath": "/swagger/v1/all-apis.json",
    "Title": "All APIs Documentation"
  }
}

Gateway Mode (With Caching)

{
  "Koalesce": {
    "Sources": [
      {
        "Url": "https://localhost:8001/swagger/v1/swagger.json",
        "VirtualPrefix": "/customers"
      },
      {
        "Url": "https://localhost:8002/swagger/v1/swagger.json",
        "VirtualPrefix": "/inventory"
      }
    ],
    "MergedDocumentPath": "/swagger/v1/apigateway.json",
    "Title": "API Gateway",
    "ApiGatewayBaseUrl": "https://localhost:5000", // <-----
    "Cache": {  // <-----
      "AbsoluteExpirationSeconds": 86400,
      "SlidingExpirationSeconds": 300
    }
  }
}

Mixed Sources (HTTP + Local Files)

Useful when merging live APIs with downloaded specifications from public APIs:

{
  "Koalesce": {
    "Sources": [
      { "Url": "https://localhost:8001/swagger/v1/swagger.json" },
      { "FilePath": "./specs/external-api.json" }
    ],
    "MergedDocumentPath": "/swagger/v1/merged.json",
    "Title": "Combined API Documentation"
  }
}

Note: File paths can be absolute or relative. Relative paths are resolved from the application's base directory.

Strict Mode

{
  "Koalesce": {
    "Sources": [
      { "Url": "https://localhost:8001/swagger/v1/swagger.json" },
      { "Url": "https://localhost:8002/swagger/v1/swagger.json" }
    ],
    "MergedDocumentPath": "/swagger/v1/apigateway.yaml",
    "Title": "API Gateway",
    "ApiGatewayBaseUrl": "https://localhost:5000",
    "FailOnServiceLoadError": true, // <-----
    "SkipIdenticalPaths": false     // <-----
  }
}

Security Schemas

Koalesce is non-opinionated about security - authentication and authorization are responsibilities of your APIs and Gateway.

  • Operations with security in downstream APIs keep their security requirements
  • Operations without security remain public
  • Mixed public/private scenarios are supported naturally
  • Each API's security scheme is preserved in the merged document

Conflict Resolution

Path Conflicts

Strategy Configuration Behavior
Preserve All (Recommended) Use VirtualPrefix /api/health becomes /inventory/api/health
First Wins (Default) No prefix, SkipIdenticalPaths: true First source keeps path, duplicates skipped
Fail-Fast SkipIdenticalPaths: false Throws exception on any collision

Schema Name Conflicts

Scenario Result
Both sources have VirtualPrefix Both schemas renamed (e.g., Inventory_Product, Catalog_Product)
Only one source has VirtualPrefix Only prefixed source's schema is renamed
Neither has VirtualPrefix First keeps original name, second uses sanitized API Title

CLI Tool

Install globally to merge OpenAPI specs without hosting an app:

dotnet tool install --global Koalesce.OpenAPI.CLI --prerelease
koalesce --config ./appsettings.json --output ./gateway.yaml --verbose


License

Koalesce is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Koalesce.OpenAPI:

Repository Stars
falberthen/EcommerceDDD
Experimental full-stack application showcasing Domain-Driven Design, Microservices, Event Sourcing, CQRS and Angular.
Version Downloads Last Updated
1.0.0-alpha.12 85 1/28/2026 1.0.0-alpha.12 is deprecated.
1.0.0-alpha.11 58 1/26/2026
1.0.0-alpha.10 61 1/23/2026
1.0.0-alpha.9 57 1/22/2026
1.0.0-alpha.8 57 1/20/2026
1.0.0-alpha.7 56 1/20/2026
1.0.0-alpha.6 51 1/18/2026
1.0.0-alpha.5 59 1/16/2026
1.0.0-alpha.4 61 1/14/2026
1.0.0-alpha.3 68 1/11/2026
1.0.0-alpha.2 64 1/5/2026
1.0.0-alpha.1 65 1/2/2026
0.1.1-alpha.2 287 4/11/2025
0.1.1-alpha.1 159 4/10/2025
0.1.0-alpha 223 3/16/2025