Skip to content

Extensions no longer enforced to be spec compliant between OpenAPI 3 and OpenAPI 3.1 #4850

Open
@kjc14f

Description

@kjc14f

Description
I just switched my OpenAPI spec from 3 to 3.1, and I have noticed a breaking change where my Swagger JSON no longer has compliant path extensions.
I had a look through the code and it appears to be due to this line in AnnotationUtils .
String decoratedName = openapi31 ? name : StringUtils.prependIfMissing(name, "x-", new CharSequence[0]);

If openapi31 is true, the calculation of decoratedName is different, and no longer has x- prefixed.

I was looking at the OpenAPI 3.1 spec and it says The field name MUST begin with x- so I wanted to check if this logic is correct by default?

From the above, it seems you MUST have the x- prefix to be compliant with the spec so this class no longer prefixing it by default seems undesirable as well as a potential breaking change when moving to the new version.
I appreciate having a flag to override this default might be useful for specific use cases that want to deviate from the spec, but as a default adding it seems to make the most sense to me, like OpenAPI 3 was.

Is there a possability to switch this default functionality back to the 3.0 approach?

Thanks for the help!

Example
Notice the decoratedName field, and by extension the key field, is now different and no longer spec compliant.
OpenAPI 3 Debug
Image

OpenAPI 3.1 Debug
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions