Skip to content

Commit c753839

Browse files
committed
Merge branch 'glimpseio-master'
2 parents 999608f + 524a1cd commit c753839

File tree

11 files changed

+500
-443
lines changed

11 files changed

+500
-443
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ const base = "test/programs/";
77

88
export function assertSchema(group: string, name: string, type: string) {
99
it(group + " should create correct schema", function() {
10-
const actual = TJS.generateSchema(TJS.getProgramFromFiles([resolve(base + group + "/" + name)]), type);
10+
let settings = TJS.defaultArgs;
11+
settings.generateRequired = true;
12+
const actual = TJS.generateSchema(TJS.getProgramFromFiles([resolve(base + group + "/" + name)]), type, settings);
1113

1214
const file = readFileSync(base + group + "/schema.json", "utf8")
1315
const expected = JSON.parse(file);
@@ -36,5 +38,7 @@ describe("schema", function () {
3638
assertSchema("array-types", "main.ts", "MyArray");
3739
assertSchema("type-aliases", "main.ts", "MyString");
3840
assertSchema("type-aliases-fixed-size-array", "main.ts", "MyFixedSizeArray");
41+
42+
assertSchema("optionals", "main.ts", "MyObject");
3943

4044
});

0 commit comments

Comments
 (0)