We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When you export an enum with one value it maps to a constant in the schema, but I expect it to map to an enum with one element.
see the reproduction in the following codesandbox: https://codesandbox.io/p/sandbox/lucid-kirch-r3rxlg
in short, the input typescript file is
export enum Test { apple = "apple", } export enum Test2 { apple = "apple", orange = "orange", }
And the command to compile into json schema is
npx typescript-json-schema index.ts '*' -o out/generated.json --required --aliasRefs --refs --titles --propOrder --noExtraProps
I expect the results to be an enum with one element
{ "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "Test": { "enum": [ "apple" ], "type": "string" }, "Test2": { "enum": [ "apple", "orange" ], "type": "string" } } }
{ "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "Test": { "const": "apple", "type": "string" }, "Test2": { "enum": [ "apple", "orange" ], "type": "string" } } }
The text was updated successfully, but these errors were encountered:
If the value can only be a single value, I would expect it to be a const. Is there any advantage to having it as a single-element enum?
const
Sorry, something went wrong.
No branches or pull requests
Description
When you export an enum with one value it maps to a constant in the schema, but I expect it to map to an enum with one element.
Reproduction
see the reproduction in the following codesandbox: https://codesandbox.io/p/sandbox/lucid-kirch-r3rxlg
in short, the input typescript file is
And the command to compile into json schema is
Expected Results
I expect the results to be an enum with one element
Actual Results
The text was updated successfully, but these errors were encountered: