enum Enum_3 {
Up = 1,
Down,
Left,
Right,
}
result:
{
"enum": [
1,
2,
3,
4,
],
"type": "number",
}
enum Enum_1 {
A = 'A',
B = 'B',
C = 'C',
}
result:
{
"enum": [
"A",
"B",
"C",
],
"type": "string",
}
enum Enum_6 {
A = 1,
B = A * 2,
C = A * B + A,
D = 1 << 2,
}
result:
{
"enum": [
1,
2,
3,
4,
],
"type": "number",
}
interface Interface_To_Enum_2 {
attr: '1' | '2' | '3';
}
result:
{
"additionalProperties": false,
"properties": {
"attr": {
"enum": [
"1",
"2",
"3",
],
"type": "string",
},
},
"required": [
"attr",
],
"type": "object",
}
export namespace NameSpaceParent {
export namespace NameSpaceChild {
export namespace NameSpaceChildren {
export interface A {
name: string;
attr: NameSpaceParent.NameSpaceChild.NameSpaceChildren.B;
}
export interface B {
name1: string;
}
export enum Label {
LABEL_OPTIONAL = 1,
LABEL_REQUIRED = 2,
LABEL_REPEATED = 3,
}
}
}
}
interface Interface_To_Enum_4 {
attr:
| '1'
| '2'
| '3'
| true
| 1
| NameSpaceParent.NameSpaceChild.NameSpaceChildren.Label
| Array<
| NameSpaceParent.NameSpaceChild.NameSpaceChildren.A
| NameSpaceParent.NameSpaceChild.NameSpaceChildren.B
>;
}
result:
{
"additionalProperties": false,
"definitions": {
"NameSpaceParent.NameSpaceChild.NameSpaceChildren.A": {
"additionalProperties": false,
"properties": {
"attr": {
"$ref": "#/definitions/NameSpaceParent.NameSpaceChild.NameSpaceChildren.B",
},
"name": {
"type": "string",
},
},
"required": [
"name",
"attr",
],
"type": "object",
},
"NameSpaceParent.NameSpaceChild.NameSpaceChildren.B": {
"additionalProperties": false,
"properties": {
"name1": {
"type": "string",
},
},
"required": [
"name1",
],
"type": "object",
},
"NameSpaceParent.NameSpaceChild.NameSpaceChildren.Label": {
"enum": [
1,
2,
3,
],
"type": "number",
},
},
"properties": {
"attr": {
"anyOf": [
{
"$ref": "#/definitions/NameSpaceParent.NameSpaceChild.NameSpaceChildren.Label",
},
{
"items": {
"anyOf": [
{
"$ref": "#/definitions/NameSpaceParent.NameSpaceChild.NameSpaceChildren.A",
},
{
"$ref": "#/definitions/NameSpaceParent.NameSpaceChild.NameSpaceChildren.B",
},
],
},
"type": "array",
},
{
"enum": [
"1",
"2",
"3",
true,
1,
],
},
],
},
},
"required": [
"attr",
],
"type": "object",
}