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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@


class AnAllOfEnum(str, Enum):
FOO = "foo"
BAR = "bar"
A_DEFAULT = "a_default"
BAR = "bar"
FOO = "foo"
OVERRIDDEN_DEFAULT = "overridden_default"

def __str__(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

class GetLocationHeaderTypesStringEnumHeader(str, Enum):
ONE = "one"
TWO = "two"
THREE = "three"
TWO = "two"

def __str__(self) -> str:
return str(self.value)
2 changes: 1 addition & 1 deletion openapi_python_client/templates/str_enum.py.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from enum import Enum

class {{ enum.class_info.name }}(str, Enum):
{% for key, value in enum.values.items() %}
{% for key, value in enum.values|dictsort(true) %}
{{ key }} = "{{ value }}"
{% endfor %}

Expand Down