Skip to content

Commit ee68841

Browse files
committed
Generate required array for non-optional properties
1 parent 999608f commit ee68841

File tree

11 files changed

+497
-442
lines changed

11 files changed

+497
-442
lines changed

test/programs/class-single/schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"propB": {
99
"type": "number"
1010
}
11-
}
11+
},
12+
"required": [ "propA", "propB" ]
1213
}

test/programs/enums-string/schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"$ref": "#/definitions/Enum"
66
}
77
},
8+
"required": [ "foo" ],
89
"definitions": {
910
"Enum": {
1011
"type": "string",
@@ -16,4 +17,4 @@
1617
}
1718
},
1819
"$schema": "http://json-schema.org/draft-04/schema#"
19-
}
20+
}

test/programs/interface-multi/schema.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"$ref": "#/definitions/MySubObject"
1010
}
1111
},
12+
"required": [ "subA", "subB" ],
1213
"definitions": {
1314
"MySubObject": {
1415
"type": "object",
@@ -19,7 +20,8 @@
1920
"propB": {
2021
"type": "number"
2122
}
22-
}
23+
},
24+
"required": [ "propA", "propB" ]
2325
}
2426
}
2527
}

test/programs/interface-single/schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"propB": {
99
"type": "number"
1010
}
11-
}
11+
},
12+
"required": [ "propA", "propB" ]
1213
}

test/programs/module-interface-single/schema.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"type": "number"
99
}
1010
},
11+
"required": [ "propA", "propB" ],
1112
"$schema": "http://json-schema.org/draft-04/schema#"
1213
}

test/programs/optionals/main.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
interface MyObject {
2+
required:number;
3+
optional?:number;
4+
}

test/programs/optionals/schema.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"type": "object",
4+
"required": [ "required" ],
5+
"properties": {
6+
"required": {
7+
"type": "number"
8+
},
9+
"optional": {
10+
"type": "number"
11+
}
12+
}
13+
}

test/schema.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,7 @@ describe("schema", function () {
3636
assertSchema("array-types", "main.ts", "MyArray");
3737
assertSchema("type-aliases", "main.ts", "MyString");
3838
assertSchema("type-aliases-fixed-size-array", "main.ts", "MyFixedSizeArray");
39+
40+
assertSchema("optionals", "main.ts", "MyObject");
3941

4042
});

0 commit comments

Comments
 (0)