You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
With other generators, spaces in enum values work perfectly fine. But with openapi-python-generator, spaces are replaced by underscores. This causes the generated client to be incompatible with the actual service!
I traced this behavior to where this regex determining value_dict["enum"] values to feed the ENUM_TEMPLATE Jinja template. I'm not experienced with Jinja, but I expect a separate key-value pair could be used with it somehow instead.
To Reproduce
Define an enum with spaces in one or more values, e.g.
class ThingType(str, Enum):
BIG_THING = "big_thing"
SMALL_THING = "small_thing"
Expected behavior
Enum names should have invalid characters converted to underscores, but the values should be preserved. In the above example, I would expect:
Describe the bug
With other generators, spaces in enum values work perfectly fine. But with
openapi-python-generator
, spaces are replaced by underscores. This causes the generated client to be incompatible with the actual service!I traced this behavior to where this regex determining
value_dict["enum"]
values to feed theENUM_TEMPLATE
Jinja template. I'm not experienced with Jinja, but I expect a separate key-value pair could be used with it somehow instead.To Reproduce
Define an enum with spaces in one or more values, e.g.
The resulting model looks like this:
Expected behavior
Enum names should have invalid characters converted to underscores, but the values should be preserved. In the above example, I would expect:
Additional context
I attached a sample OpenAPI spec that trivially causes this to happen.
enum_with_spaces.json
The text was updated successfully, but these errors were encountered: