Skip to content

[Feature] Support enumNames-like setting to generate enum with custom names #96

Closed
@songzhi

Description

@songzhi

There's basically tow options.The first is use another field likeenumNames:string[] in OpenApiSchema to generate enums with custom names.
Schema like this:

"state": {
    "title": "State",
    "enum": [
        0,
        1,
        2
    ],
    "type": "integer",
    "default": 0,
    "enumNames": ["initial", "working", "finished"]
}

Generated code:

enum state {
  INITIAL = 0,
  WORKING = 1,
  FINISHED = 2
}

But enumNames is not a valid openapi schema field.
Another option is expanding the getEnumFromDescription.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions