Closed
Description
Is your feature request related to a problem? Please describe.
When two components have an enum field with the same name, the second Enum
class generated is just incremented with a number. For instance, given a field status
, the two generated classes will be Status
and Status1
. It makes for a rather unhelpful name.
Given spec snippet:
CheckoutRecord:
type: object
properties:
status:
type: string
enum: ['AVAILABLE', 'RESERVED', 'CHECKED_OUT']
Task:
type: object
properties:
status:
type: string
enum: ['RUNNING', 'SUCCEEDED', 'FAILED']
Generates Enum
classes:
class Status(str, Enum):
AVAILABLE = "AVAILABLE"
RESERVED = "RESERVED"
CHECKED_OUT = "CHECKED_OUT"
class Status1(str, Enum):
RUNNING = "RUNNING"
SUCCEEDED = "SUCCEEDED"
FAILED = "FAILED"
Describe the solution you'd like
I think the best thing to have for compatibility here might be to add an option to the generator which will prepend the component name to the generated Enum
class.
For example, given the example above the two generated Enum
s would be CheckoutRecordStatus
and TaskStatus
. Naming collision is very unlikely in this case and the names are much more helpful.