OpenAPI generated struct fields are (avoidably) sorted alphabetically in endpoints, contradicting Swagger example order
Full discussion thread:
!3326 (comment 1774819024)
https://gitlab.com/thorchain/thornode/-/blob/v1.127.0/openapi/openapi.yaml
allows indicating struct fields in a custom order (for instance intuitively with a defining name at the top),
and this custom order is reflected in the Swagger representation of the expected endpoint response.
However, the actual display
(in contrast with non-OpenAPI structs such as at
https://thornode-v1.ninerealms.com/thorchain/balance/module/reserve )
has the fields uncomfortably sorted in alphabetical order.
This currently appears to be due to that OpenAPI also generates an overriding MarshalJSON
function
which converts the struct (unsorted in marshaling) to a map (sorted in marshaling).
https://gitlab.com/thorchain/thornode/-/blob/v1.127.0/openapi/gen/model_thorname.go#L223-244
Knowing this, it appears possible to
Remembering the recent !3425 (merged) and my comment here
!3425 (comment 1772569765)
, I also suggest moving Makefile's generate:
's OpenAPI file-modification lines to openapi:
instead so that can't be accidentally skipped.
Specifically: !3432 (merged)
'Display OpenAPI-struct endpoint responses consistently with their Swagger examples'.