Closed
Description
Description
When there are multiple keys that cannot be represented as properties, the generated enum converts them all to _
, which makes it impossible to use those values in the enum.
Name | Version |
---|---|
openapi-typescript |
7.0.0 |
Node.js | 20 |
OS + version | Linux |
Reproduction
A decent example is the Intercom OpenAPI spec: https://github.com/intercom/Intercom-OpenAPI/blob/main/descriptions/2.11/api.intercom.io.yaml
When generating types using:
openapi-typescript ./api.intercom.io.yaml --enum -o ./intercom.d.ts
It results in an enum that looks like this:
export enum Single_filter_search_requestOperator {
_ = "=",
_ = "!=",
IN = "IN",
NIN = "NIN",
_ = "<",
_ = ">",
_ = "~",
_ = "!~",
_ = "^",
$ = "$"
}
Expected result
Quoted key names if they are not valid javascript properties. For example, something like this:
export enum Single_filter_search_requestOperator {
"=" = "=",
"!=" = "!=",
IN = "IN",
NIN = "NIN",
"<" = "<",
">" = ">",
"~" = "~",
"!~" = "!~",
"^" = "^",
$ = "$"
}
Checklist
- My OpenAPI schema passes the Redocly validator (
npx @redocly/cli@latest lint
) - I’m willing to open a PR (see CONTRIBUTING.md)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done