Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
DanDeMicco opened this issue Aug 21, 2024 · 0 comments
Open
2 tasks done

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

DanDeMicco opened this issue Aug 21, 2024 · 0 comments
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library

Comments

@DanDeMicco
Copy link

DanDeMicco commented Aug 21, 2024

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

@DanDeMicco DanDeMicco added bug Something isn't working openapi-ts Relevant to the openapi-typescript library labels Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working openapi-ts Relevant to the openapi-typescript library
Projects
None yet
Development

No branches or pull requests

1 participant