oapi-codegen icon indicating copy to clipboard operation
oapi-codegen copied to clipboard

x-order not respected when using $ref

Open bjarnemagnussen opened this issue 9 months ago • 2 comments

When using referencing, e.g.:

"properties": {
    "$ref": "#/components/schemas/Properties",
    "x-order": 2
},

Then the x-order is not respected. Only if it is put on the actual referenced feature Properties.

Is this expected, or should it be possible to override the x-order value of the feature when defined directly after referencing it?

bjarnemagnussen avatar May 15 '24 12:05 bjarnemagnussen

I think this is expected due to our use of OpenAPI 3.0.

When we support OpenAPI 3.1 (#373) it will then be possible to add arbitrary keywords next to $ref https://github.com/OAI/OpenAPI-Specification/discussions/3526

jamietanna avatar May 16 '24 07:05 jamietanna

The spec says there should be no properties next to $ref. But, in my opinion, extensions are an exception.

The core technical problem is kin-openapi is not capturing anything next to $ref.

kin-openapi issue with more information https://github.com/getkin/kin-openapi/issues/900 kin-openapi pr to capture extensions next to $ref https://github.com/getkin/kin-openapi/pull/901

After the pr is merge, we can make the relatively small changes here to address this. However, right now I'm blocked on the merge/release of the upstream change.

paulmach avatar Jun 10 '24 16:06 paulmach

Thanks for the work upstream with this @paulmach, this is now fixed on HEAD, and will be released with the next release (no ETA yet)

jamietanna avatar Jul 09 '24 08:07 jamietanna

This issue is not fully fixed, it was a 3 parter.

  1. have kin-openapi read in the extensions next to $ref https://github.com/getkin/kin-openapi/pull/901
  2. upgrade the kin-openapi version used here https://github.com/oapi-codegen/oapi-codegen/pull/1689
  3. make use of those values in this library https://github.com/oapi-codegen/oapi-codegen/pull/1700

part 3 still needs to happen

paulmach avatar Jul 13 '24 17:07 paulmach

I am still experiencing this issue using the latest version v2.3.0, I see there is an open pr #1700 and was wondering if this will be merged soon?

AndrewCopeland avatar Jul 23 '24 23:07 AndrewCopeland

Sorry if meant to come back to this one, will merge (but not release) today

jamietanna avatar Jul 24 '24 06:07 jamietanna