Bug Report Checklist
Description
Euro symbol in enum creates invalid code.
openapi-generator version
v7.17.0 (latest)
OpenAPI declaration file content or url
openapi: 3.1.0
info:
version: 0.1.0
title: ''
description: ''
components:
schemas:
Currency:
type: string
enum:
- "$"
- "€"
Generation Details
# build openapi generator from source
./mvnw clean install
# generate python code
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate --generator-name python --input-spec spec.yaml --output "euro-fix-output"
Steps to reproduce
Look into euro-fix-output/openapi_client/models/currency.py. The generated enum looks like this:
class Currency(str, Enum):
"""
Currency
"""
"""
allowed enum values
"""
DOLLAR = '$'
€ = '€' # <------------- this is causing problems
@classmethod
def from_json(cls, json_str: str) -> Self:
"""Create an instance of Currency from a JSON string"""
return cls(json.loads(json_str))
Instead it should look like this:
class Currency(str, Enum):
"""
Currency
"""
"""
allowed enum values
"""
DOLLAR = '$'
EURO = '€' # <------------- expected code
@classmethod
def from_json(cls, json_str: str) -> Self:
"""Create an instance of Currency from a JSON string"""
return cls(json.loads(json_str))
Related issues/PRs
Suggest a fix
Will contribute it 😄
Bug Report Checklist
Description
Euro symbol in enum creates invalid code.
openapi-generator version
v7.17.0(latest)OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Look into
euro-fix-output/openapi_client/models/currency.py. The generated enum looks like this:Instead it should look like this:
Related issues/PRs
Suggest a fix
Will contribute it 😄