Skip to content

feat: Always generate enums with sorted members #728

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

Merged
merged 4 commits into from
Mar 12, 2023

Conversation

expobrain
Copy link
Collaborator

The code generator always renders the enum members in alphabetical order so that to minimise the changes in the generated code.

Tl;RL

Previously the enum members were collected as a dictionary in a random order and rendered as is, this was causing multiple run of the code generator to render the enum members in different order. If the generated code is then committed in a VCS it would create unnecessary changes because of the different order of the semantically same enum definition.

With this change the enum members are always rendered in alphabetical order so enums that are semantically the same will be rendered also the same in the code.

@dbanty
Copy link
Collaborator

dbanty commented Feb 22, 2023

I don't think the order was random, it should have been the order in which they were declared, so it should be consistent between runs.

However, this is better since even reordering the declaration in the schema shouldn't generate different code.

I wonder if we should do this with properties of objects as well 🤔

@codecov
Copy link

codecov bot commented Feb 22, 2023

Codecov Report

Merging #728 (543db4d) into main (5f85ac5) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##              main      #728   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           49        49           
  Lines         1971      1971           
=========================================
  Hits          1971      1971           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@expobrain
Copy link
Collaborator Author

Probably yes, but in another PR

@dbanty dbanty changed the title Always generate enums with sorted members feat: Always generate enums with sorted members Mar 12, 2023
dbanty
dbanty previously approved these changes Mar 12, 2023
@dbanty dbanty merged commit a1e1a68 into openapi-generators:main Mar 12, 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