-
Notifications
You must be signed in to change notification settings - Fork 283
Description
Summary
When generating OpenAPI documents with OpenApiSpecVersion ≤ 3.1, the library emits RFC 6570 URI template syntax such as:
"/files/{+path}": {
"get": {
"tags": ["Files"]
}
}This syntax is only valid in OpenAPI 3.2, which formally adopts RFC 6570 URI Templates.
In OpenAPI 3.0 and 3.1, {+path} is out of spec and has no defined meaning.
Expected behavior
When targeting OpenAPI 3.0 or 3.1, path templates should be restricted to:
/files/{path}
Specifically:
- No RFC 6570 operators (
+,*,?,#,&) - No multi-segment semantics
- No reserved expansion
Actual behavior
For OpenApiSpecVersion <= 3.1, the generated document contains:
/files/{+path}
This results in:
- ❌ Invalid OpenAPI 3.0 / 3.1 documents
- ❌ Rejection by strict validators
- ❌ Undefined behavior in tooling and code generators
Specification references
-
OpenAPI 3.0 / 3.1
- Path templating supports simple parameters only (
{param}) - RFC 6570 is not referenced or adopted
- Path templating supports simple parameters only (
-
OpenAPI 3.2
- Formally adopts RFC 6570 URI Templates
{+path}becomes valid and meaningful
Suggested resolution
One of the following (or similar):
-
Version-aware generation
- Emit
{+param}only whenOpenApiSpecVersion >= 3.2 - Downgrade to
{param}for earlier versions
- Emit
-
Validation / guardrail
- Throw or warn when RFC 6570 operators are used with OpenAPI ≤ 3.1
-
Explicit opt-in
- Require a flag or setting to enable RFC 6570 features
Why this matters
Many frameworks (e.g., ASP.NET Core) support multi-segment routing internally (e.g., {**path}), but OpenAPI ≤ 3.1 cannot represent this legally.
Emitting {+path} for those versions produces specs that appear valid but are not.
Additional context
OpenAPI 3.2 resolves this cleanly by aligning with RFC 6570.
This issue is about ensuring correct version targeting and spec compliance for earlier versions.