smallrye-open-api icon indicating copy to clipboard operation
smallrye-open-api copied to clipboard

Extensions in static file aren't available via extension methods

Open MikeEdgar opened this issue 7 months ago • 2 comments

When we load an OAS 3.1 document from JSON/YAML, unknown fields are not currently identified as extensions since they are being added via set. Either Schema#set should be aware of the known properties so that unknown properties are internally identified as extensions, or we should call addExtension when processing these properties:

https://github.com/smallrye/smallrye-open-api/blob/9cf2fedd6610ac885e2543522b0786e2eb099f98/core/src/main/java/io/smallrye/openapi/runtime/io/media/SchemaIO.java#L126-L134

MikeEdgar avatar Jun 13 '25 17:06 MikeEdgar

We discussed this at the call today. It's a bit confusing, Schema has separate get and set methods for setting arbitrary properties, and Extensible says that extensions should begin "x-". On the other hand, we don't enforce the extension key prefix afaik and it seems intuitive that anything that's not a known field is an extension.

We noted the following things to check:

  • What do we do when reading and writing OAS 3.0 documents? Extensions there are required to start x-
  • Do we have any TCK tests regarding extensions for OAS 3.1 schemas?

We also noted that currently, x- keys do not appear as extensions either.

Azquelt avatar Jun 24 '25 16:06 Azquelt

What do we do when reading and writing OAS 3.0 documents? Extensions there are required to start x-

  • For 3.1 schemas, extensions are populated directly on the schema using set
  • For 3.0 schemas, extensions are loaded using ExtensionIO, which populates the schema via addExtension and filters the input properties by the x- prefix.
  • For other object types, ExtensionIO is used to determine if a property is an extension (x-) and adding the key/value via addExtension.

Do we have any TCK tests regarding extensions for OAS 3.1 schemas?

I was unable to locate any TCK tests that check reading of extensions from a static file - only annotations are checked.

MikeEdgar avatar Jul 15 '25 12:07 MikeEdgar