Skip to content

Conversation

bg451
Copy link
Contributor

@bg451 bg451 commented Apr 14, 2023

Users can pass in --keep-spec-order to maintain the field order when generating go code. This flag is not actually respected, and fields are generated in alphabetical order. The reason for this is WithAutoXOrder generates a new YAML with x-order set on definition properties, however the new spec YAML is never actually used. This PR fixes this by reloading g.Spec if PropertiesSpecOrder is set.

The bug can be reproduced by running swagger@HEAD against https://github.com/go-swagger/go-swagger/blob/master/fixtures/codegen/keep-spec-order.yml, e.g. swagger generate client --spec keep-spec-order.yml --keep-spec-order

cc @casualjim

@casualjim casualjim force-pushed the fix_keep_spec_order branch from 19a3f11 to 06db593 Compare April 25, 2023 21:52
Users can pass in --keep-spec-order to maintain the field order when
generating go code. This flag is not actually respected, and fields are
generated in alphabetical order. The reason for this is WithAutoXOrder
generates a new YAML with x-order set on definition properties, however
the new spec YAML is never actually used. This PR fixes this by
reloading g.Spec if PropertiesSpecOrder is set.
@casualjim casualjim force-pushed the fix_keep_spec_order branch from 06db593 to feeb9c3 Compare April 26, 2023 22:10
@casualjim casualjim merged commit 4fb3bdd into go-swagger:master Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants