openapi-typescript version
7.13.0
Node.js version
26.1.0
OS + version
Linux
Description
If an enum has an empty string as an expected value, the generated TypeScript enum is invalid code since it tries to assign it to an empty label.
Reproduction
Run openapi-typescript --enum on this file:
{
"openapi": "3.1.0",
"info": {
"title": "Test",
"summary": "Test",
"description": "Test",
"version": "0.1.0",
"license": {
"name": "MIT",
"identifier": "MIT"
}
},
"servers": [
{
"url": "https://bexample.com"
}
],
"paths": {
"/test": {
"get": {
"summary": "Test",
"operationId": "test",
"security": [
{}
],
"parameters": [
{
"name": "type",
"in": "query",
"required": false,
"schema": {
"enum": [
"",
"foo",
"bar"
],
"type": "string",
"default": "",
"title": "Type"
}
}
]
}
}
}
}
Expected result
The enums generated are valid TypeScript. Get this instead:
export enum PathsTestGetParametersQueryType {
= "",
foo = "foo",
bar = "bar"
}
Required
Extra
openapi-typescript version
7.13.0
Node.js version
26.1.0
OS + version
Linux
Description
If an enum has an empty string as an expected value, the generated TypeScript enum is invalid code since it tries to assign it to an empty label.
Reproduction
Run
openapi-typescript --enumon this file:{ "openapi": "3.1.0", "info": { "title": "Test", "summary": "Test", "description": "Test", "version": "0.1.0", "license": { "name": "MIT", "identifier": "MIT" } }, "servers": [ { "url": "https://bexample.com" } ], "paths": { "/test": { "get": { "summary": "Test", "operationId": "test", "security": [ {} ], "parameters": [ { "name": "type", "in": "query", "required": false, "schema": { "enum": [ "", "foo", "bar" ], "type": "string", "default": "", "title": "Type" } } ] } } } }Expected result
The enums generated are valid TypeScript. Get this instead:
Required
npx @redocly/cli@latest lint)Extra