Skip to content

Incorrect generation of RFC 6570 {+param} in OpenAPI versions ≤ 3.1 #2704

@mdaneri

Description

@mdaneri

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
  • OpenAPI 3.2

    • Formally adopts RFC 6570 URI Templates
    • {+path} becomes valid and meaningful

Suggested resolution

One of the following (or similar):

  1. Version-aware generation

    • Emit {+param} only when OpenApiSpecVersion >= 3.2
    • Downgrade to {param} for earlier versions
  2. Validation / guardrail

    • Throw or warn when RFC 6570 operators are used with OpenAPI ≤ 3.1
  3. 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.

References

RFC 6570 – URI Template (IETF)

https://www.rfc-editor.org/rfc/rfc6570.html

https://spec.openapis.org/oas/v3.2.0.html#path-templating

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions