Koalesce.OpenAPI
1.0.0-alpha.2
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
<PackageReference Include="Koalesce.OpenAPI" Version="1.0.0-alpha.2" />
<PackageVersion Include="Koalesce.OpenAPI" Version="1.0.0-alpha.2" />
<PackageReference Include="Koalesce.OpenAPI" />
paket add Koalesce.OpenAPI --version 1.0.0-alpha.2
#r "nuget: Koalesce.OpenAPI, 1.0.0-alpha.2"
#:package Koalesce.OpenAPI@1.0.0-alpha.2
#addin nuget:?package=Koalesce.OpenAPI&version=1.0.0-alpha.2&prerelease
#tool nuget:?package=Koalesce.OpenAPI&version=1.0.0-alpha.2&prerelease
π¨ 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
JSONorYAMLformat.
β‘ Features
- β Coalesce multiple OpenAPI definitions into one unified schema.
- β
Fully configurable via
appsettings.json. - β Aligns perfectly with API Gateways (Ocelot, YARP).
- β
Allows output a
jsonoryamlmerged 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/getbecomes/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:
- πΊ
--configspecifies the path to yourappsettings.json. - πΊ
--outputdefines the path for the merged OpenAPI spec file. --verboseenables detailed logging.--versiondisplays 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?
Use
VirtualPrefix(Recommended): Assign a unique prefix inappsettings.json(e.g.,inventory,products).- Koalesce transforms
/api/healthinto/inventory/api/health. - This ensures unique paths in the documentation.
- Requires API Gateway URL Rewrite configuration.
- Koalesce transforms
Order of Precedence:
- If
VirtualPrefixis not used, the order of OpenApiSources determines precedence. - By default (
SkipIdenticalPaths: true), duplicates are ignored (first wins).
- If
π 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 | Versions 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. |
-
net10.0
- Koalesce.Core (>= 1.0.0-alpha.2)
- Microsoft.OpenApi (>= 1.6.28)
- Microsoft.OpenApi.Readers (>= 1.6.28)
-
net8.0
- Koalesce.Core (>= 1.0.0-alpha.2)
- Microsoft.OpenApi (>= 1.6.28)
- Microsoft.OpenApi.Readers (>= 1.6.28)
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.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 |