Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

swag init generates enums in indeterministic order #1738

Open
roma-glushko opened this issue Jan 14, 2024 · 1 comment
Open

swag init generates enums in indeterministic order #1738

roma-glushko opened this issue Jan 14, 2024 · 1 comment

Comments

@roma-glushko
Copy link

Describe the bug

I have a package where I have my custom enum defined in one file:

type Strategy string

While the values of this type is defined in other files of that package like:

const (
	Priority Strategy = "priority"
)
Screenshot 2024-01-14 at 15 06 54

Also, I have a CI check that does swag init && git diff --exit-code to remind me to update API specs when the corresponding code has changed.

Expected behavior

I expect that my enum values are generated in a deterministic order, so no matter how many times I regenerate the spec it gives no changes as far as the underlying enum values stayed the same.

Actual behavior

Sometime, swag init changes the order of enum values causing changes & the CI job to fail:

Screenshot 2024-01-14 at 15 11 13 Screenshot 2024-01-14 at 15 11 40 Screenshot 2024-01-14 at 15 15 06

Your swag version
v1.16.2

Your go version
go1.21.5 darwin/amd64

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: -
  • Version: -

Additional context
Add any other context about the problem here.

@sdghchj
Copy link
Member

sdghchj commented Jan 15, 2024

It is better to declare all the enums of the same type together in one file, I think。
In this way, your can arrange their sequences according your intention.

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

No branches or pull requests

2 participants