Koalesce.OpenAPI 1.0.0-alpha.2

This is a prerelease version of Koalesce.OpenAPI.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Koalesce.OpenAPI --version 1.0.0-alpha.2
                    
NuGet\Install-Package Koalesce.OpenAPI -Version 1.0.0-alpha.2
                    
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.2" />
                    
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.2" />
                    
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.2
                    
#r "nuget: Koalesce.OpenAPI, 1.0.0-alpha.2"
                    
#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.2
                    
#: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.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Koalesce.OpenAPI&version=1.0.0-alpha.2&prerelease
                    
Install as a Cake Tool

🐨 Koalesce

Koalesce is a .NET library designed to merge multiple OpenAPI definitions into a unified document to enable seamless API Gateway integration and simplify frontend client generation for microservices-based architectures.


How It Works?

  • Koalesce fetches OpenAPI definitions from the specified OpenApiSources.
  • It then merges them using supported providers, generating a single schema at MergedOpenApiPath.
  • The final Koalesced API definition is serialized and available in JSON or YAML format.

⚑ Features

  • βœ… Coalesce multiple OpenAPI definitions into one unified schema.
  • βœ… Fully configurable via appsettings.json.
  • βœ… Aligns perfectly with API Gateways (Ocelot, YARP).
  • βœ… Allows output a json or yaml merged document regardless the document type of the source APIs.
  • βœ… Streamlines API client generation since it results in one unified schema.
  • βœ… Extensible architecture to support new API aggregation strategies.
  • βœ… Multi-targeting: Native support for .NET 8.0 (LTS) and .NET 10.0.

βš™οΈ Basic Configuration
Setting Type Default Value Description
OpenApiSources array πŸ”Ί List of API sources. Each item contains Url and optional VirtualPrefix.
MergedOpenApiPath string πŸ”Ί Path where the merged API definition is exposed.
Title string "My 🐨Koalesced OpenAPI" Title for the Koalesced API definition.
SkipIdenticalPaths boolean true If false, throws exception on duplicate paths. If true, logs warning and skips duplicates.
ApiGatewayBaseUrl string null If provided, ensures a single server URL for the merged document (essential for "Try it out").
  • πŸ’‘ Parameters listed with πŸ”Ί are required.
  • πŸ’‘ The file extension [.json, .yaml] defined in MergedOpenApiPath determines the output format.

<br>

{
  "Koalesce": {
    "OpenApiSources": [
      {
        "Url": "https://localhost:8001/swagger/v1/swagger.json",
        "VirtualPrefix": "customers"
      },
      {
        "Url": "https://localhost:8002/swagger/v1/swagger.json",
        "VirtualPrefix": "inventory"
      }
    ],
    "MergedOpenApiPath": "/swagger/v1/apigateway.json",
    "Title": "My Koalesced API",
    "SkipIdenticalPaths": true,
    "ApiGatewayBaseUrl": "https://localhost:5000",
    "Cache": {
      "DisableCache": false,
      "AbsoluteExpirationSeconds": 86400,
      "SlidingExpirationSeconds": 300,
      "MinExpirationSeconds": 30
    }
  }
}

Note on VirtualPrefix: When you define a prefix (e.g., "customers"), Koalesce modifies the path in the documentation (e.g., /api/get becomes /customers/api/get). Important: Your API Gateway (e.g., Ocelot/YARP) must be configured to route this prefixed path back to the original downstream service.


πŸ› οΈ Caching Configuration (Koalesce.Cache)

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

βš™οΈ Koalesce.OpenAPI Configuration

πŸ”Ί This configuration extends the basic settings.

Setting Type Default Value Description
Koalesce.OpenApiVersion string "3.0.1" Target OpenAPI version for the output.
{
  "Koalesce": {
    "OpenApiVersion": "3.0.1",    
    // ... same other configurations
  }
}

πŸ› οΈ Using with .NET pipeline

1️⃣ Register Koalesce.[ForProvider()]
builder.Services.AddKoalesce()
  .ForOpenAPI(); // Register Koalesce.OpenAPI provider
2️⃣ Enable Middleware
app.UseKoalesce();

πŸ› οΈ Using with Command Line Interface (CLI)

Arguments:
  • πŸ”Ί--config specifies the path to your appsettings.json.
  • πŸ”Ί--output defines the path for the merged OpenAPI spec file.
  • --verbose enables detailed logging.
  • --version displays the current version.
Example
koalesce --config ./config/appsettings.json --output ./merged-specs/apigateway.yaml

⚠️ Important Considerations and Limitations

πŸ” Security Schemes & Authorization

Koalesce merges authentication schemes found in different API definitions.

  • ⚠️ Each API's operations retain their respective security requirements.
  • ⚠️ When using Swagger UI, the Authorize prompt will display inputs for all security schemes found across the merged document.
πŸ”€ Handling Identical Routes

If two or more microservices share the same route (e.g., /api/health), a collision occurs.

πŸ”Ή How to resolve this?

  1. Use VirtualPrefix (Recommended): Assign a unique prefix in appsettings.json (e.g., inventory, products).

    • Koalesce transforms /api/health into /inventory/api/health.
    • This ensures unique paths in the documentation.
    • Requires API Gateway URL Rewrite configuration.
  2. Order of Precedence:

    • If VirtualPrefix is not used, the order of OpenApiSources determines precedence.
    • By default (SkipIdenticalPaths: true), duplicates are ignored (first wins).

πŸ“ License

Koalesce is licensed under the MIT License.

❀️ Contributing

Contributions are welcome! Feel free to open issues and submit PRs.

πŸ“§ Contact

For support or inquiries, reach out via GitHub Issues.

πŸ“œ Koalesce Changelog

See the full changelog here.

πŸ“œ Koalesce.OpenAPI.CLI Changelog

See the full changelog here.

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

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-alpha.12 136 1/28/2026 1.0.0-alpha.12 is deprecated.
1.0.0-alpha.11 84 1/26/2026
1.0.0-alpha.10 95 1/23/2026
1.0.0-alpha.9 87 1/22/2026
1.0.0-alpha.8 84 1/20/2026
1.0.0-alpha.7 83 1/20/2026
1.0.0-alpha.6 79 1/18/2026
1.0.0-alpha.5 90 1/16/2026
1.0.0-alpha.4 90 1/14/2026
1.0.0-alpha.3 99 1/11/2026
1.0.0-alpha.2 90 1/5/2026
1.0.0-alpha.1 92 1/2/2026
0.1.1-alpha.2 327 4/11/2025
0.1.1-alpha.1 177 4/10/2025
0.1.0-alpha 245 3/16/2025