Skip to content

Enum generation: OpenAPI 3.1 null enum value doesn't generate enum #1872

Open
@DanDeMicco

Description

@DanDeMicco

Description

A brief description of the bug.

I have a nullable enum yaml file (Open API 3.1) defined like:

type:
  - string
  - 'null'
...
enum:
  - VALUE1
  - VALUE2
  - null

which i have in my schema as

values:
  $ref: <relative_path>/values.yaml

This will output in the TS schema output:

values: "VALUE1" | "VALUE2" | null

with no enum emitted

Name Version
openapi-typescript 7.3.0
Node.js v18.20.4
OS + version macOS 14.6.1

Reproduction

How can this be reproduced / when did the error occur?

  1. create a nullable enum similar to the above example, reference it in API
npx openapi-typescript ./openapi.yaml -o ./src/typings/schema.d.ts --enum --alphabetize --dedupe-enums
  1. check output schema.d.ts

Expected result

  1. It should output the enum for valid values (e.g. export enum Values ...
  2. the output in the TS schema should be values: Values | null

Checklist

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions