Skip to content

Unquoted numeric enum values generate numeric enums though the schema type is string #2627

@hon2a

Description

@hon2a

openapi-typescript version

7.10.1

Node.js version

24.11.0

OS + version

macOS 26.2 (25C56)

Description

When a schema is defined as

SomeSchema:
  type: string
  enum: [ 1 ]

and "true enum" generation is turned on, it produces the following:

export enum SomeSchema {
  Value1 = 1
}

i.e. the value is numeric, though it's defined as string in the schema. Server then returns (valid) string values and numeric equality checks on the client (matching the API type) fail.

Reproduction

Already clearly defined in description.

Expected result

Already clearly defined in description.

Required

  • My OpenAPI schema is valid and passes the Redocly validator (npx @redocly/cli@latest lint)

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingopenapi-tsRelevant to the openapi-typescript library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions