oapi-codegen
oapi-codegen copied to clipboard
x-order not respected when using $ref
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?
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
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.
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)
This issue is not fully fixed, it was a 3 parter.
- have kin-openapi read in the extensions next to $ref https://github.com/getkin/kin-openapi/pull/901
- upgrade the kin-openapi version used here https://github.com/oapi-codegen/oapi-codegen/pull/1689
- make use of those values in this library https://github.com/oapi-codegen/oapi-codegen/pull/1700
part 3 still needs to happen
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?
Sorry if meant to come back to this one, will merge (but not release) today