๐ Conflict Resolution
February 21, 2026 ยท View on GitHub
When merging multiple OpenAPI specs, conflicts are inevitable. Koalesce handles path conflicts and schema conflicts with explicit strategies โ no silent data loss.
๐ฐ Identical Paths
When two services define the same path (e.g., /api/health), there's no perfect solution. Koalesce gives you three strategies โ each with clear trade-offs:
Strategy 1๏ธโฃ: VirtualPrefix (Preserve All Paths) โญ Recommended
{
"Sources": [
{ "Url": "https://inventory-api/swagger.json", "VirtualPrefix": "/inventory" },
{ "Url": "https://catalog-api/swagger.json", "VirtualPrefix": "/catalog" }
]
}
Result:
Original paths: Merged spec:
/api/health โ /inventory/api/health
/api/health โ /catalog/api/health
โ Pros:
- All endpoints preserved.
- No data loss.
- Explicit service boundaries in merged spec.
โ ๏ธ Cons:
- Requires Gateway URL rewrite (Ocelot, YARP, Kong, etc.).
- Gateway must strip prefix before routing to actual service.
- More configuration needed.
Use when: You have a Gateway and want complete API coverage.
Strategy 2๏ธโฃ: First Source Wins (Default)
{
"Sources": [
{ "Url": "https://inventory-api/swagger.json" },
{ "Url": "https://catalog-api/swagger.json" }
]
}
Result:
Source Path Merged spec
Inventory API โ /api/health โ โ
Included
Catalog API โ /api/health โ โ ๏ธ Skipped (warning logged)
โ Pros:
- Zero Gateway configuration.
- Predictable behavior.
- Works out-of-the-box.
โ ๏ธ Cons:
- Later sources lose conflicting paths.
- Not suitable if you need all endpoints.
- Health checks, status endpoints often duplicated.
Use when: You're okay with losing duplicate paths, or paths are naturally unique
Strategy 3๏ธโฃ: Fail-Fast (Strict Mode)
{
"Sources": [
{ "Url": "https://inventory-api/swagger.json" },
{ "Url": "https://catalog-api/swagger.json" }
],
"SkipIdenticalPaths": false
}
Result:
โ KoalesceIdenticalPathFoundException
Duplicate path detected: /api/health
Sources: inventory-api, catalog-api
โ Pros:
- Forces you to resolve conflicts explicitly.
- Perfect for CI/CD validation.
- No silent data loss.
โ ๏ธ Cons:
- Requires upfront path design coordination
- Fails on common paths like
/health,/ready
Use when: You want strict contract enforcement or are validating service designs
๐ฐ Identical Schemas
When multiple APIs define schemas with the same name, Koalesce first checks whether the schemas are structurally identical. Identical schemas are deduplicated โ only one copy is kept and all references from both sources point to it. This is particularly common with framework-generated types like ASP.NET Core's ProblemDetails and ValidationProblemDetails, which appear identically across every microservice.
When schemas with the same name have different content, Koalesce automatically renames them using the (customizable) pattern {Prefix}{SchemaName}.
Conflict Behavior (when schemas are structurally different):
| Scenario | Result |
|---|---|
Both sources have VirtualPrefix | Both schemas are renamed (e.g., InventoryProduct, CatalogProduct.) |
Only one source has VirtualPrefix | Only the prefixed source's schema is renamed |
Neither source has VirtualPrefix | First schema keeps original name. Second uses Sanitized API Title as prefix. |
๐ก Note: When falling back to the API Title, Koalesce sanitizes the string (PascalCase, alphanumeric only) to ensure valid C# identifiers. For example,
"Sales API v2"becomesSalesApiV2.
Prefix Priority:
- VirtualPrefix (if configured):
/inventoryโInventoryProduct - API Name (sanitized):
Koalesce.Samples.InventoryAPIโKoalesceSamplesInventoryAPIProduct
๐ Identical Security Schemes
When multiple APIs define security schemes with the same key (e.g., "bearerAuth"), Koalesce compares their functional properties (type, scheme, name, in, bearerFormat, openIdConnectUrl). Identical schemes are deduplicated; conflicting schemes are renamed using the same rules as schema conflicts.
Conflict Behavior:
| Scenario | Result |
|---|---|
| Schemes are semantically identical | Deduplicated โ only one copy is kept |
Both sources have VirtualPrefix | Both schemes are renamed (e.g., InventorybearerAuth, CatalogbearerAuth) |
Only one source has VirtualPrefix | Only the prefixed source's scheme is renamed |
Neither source has VirtualPrefix | First scheme keeps original name. Second uses Sanitized API Title as prefix. |
๐ก Note: Security references in both document-level and operation-level
securityrequirements are automatically rewritten to match the renamed scheme keys.
๐ค Which strategy is the best for you?
Conflicts are an architectural decision, not a technical problem. Koalesce makes the trade-offs explicit and lets you choose the strategy that fits your architecture.
Recommendation:
- Use
VirtualPrefixwith a Gateway for production. - Use
First Winsfor simple scenarios or development. - Use
Fail-Fastin CI/CD to enforce path uniqueness.