-
Notifications
You must be signed in to change notification settings - Fork 393
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
Referencing specific enum values? #600
Labels
Comments
You can do something like this: {
"title": "Example Schema",
"type": "object",
"definitions": {
"circle": {
"type": "string",
"enum": [
"circle"
]
},
"square": {
"type": "string",
"enum": [
"square"
]
},
"shape": {
"oneOf": [
{
"$ref": "#/definitions/circle"
},
{
"$ref": "#/definitions/square"
}
]
}
},
"properties": {
"shape": {
"$ref": "#/definitions/shape"
}
}
} => /* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
export type Shape = Circle | Square;
export type Circle = "circle";
export type Square = "square";
export interface ExampleSchema {
shape?: Shape;
[k: string]: unknown;
} |
Thank you @bcherny! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is it possible to reference a specific enum value that is defined in another referenced definition? For example in defining a discriminating union:
Ideally it would output something like this:
The text was updated successfully, but these errors were encountered: