Skip to content

Commit f5101cc

Browse files
committed
support for advanced types
1 parent aa9a936 commit f5101cc

File tree

9 files changed

+186
-84
lines changed

9 files changed

+186
-84
lines changed

test/programs/array-types/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
interface MyArray {
22
[index: number]: string | number;
3-
}
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
type MyFixedSizeArray = [string, number];
2+

test/programs/type-aliases-fixed-size-array/schema.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
{"type": "string"},
66
{"type": "number"}
77
],
8-
"minItems": 2,
9-
"maxItems": 2
8+
"additionalItems": {
9+
"anyOf": [
10+
{"type": "string"},
11+
{"type": "number"}
12+
]
13+
},
14+
"minItems": 2
1015
}

test/programs/type-aliases/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
type MyString = string;
1+
type MyString = string;

test/schema.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {resolve} from 'path';
55

66
const base = "test/programs/";
77

8-
function assertSchema(group: string, name: string, type: string) {
8+
export function assertSchema(group: string, name: string, type: string) {
99
it(group + " should create correct schema", function() {
1010
const actual = TJS.generateSchema(TJS.getProgramFromFiles([resolve(base + group + "/" + name)]), type);
1111

@@ -32,4 +32,9 @@ describe("schema", function () {
3232

3333
// not yet working
3434
// assertSchema("string-literals", "main.ts", "result");
35+
36+
assertSchema("array-types", "main.ts", "MyArray");
37+
assertSchema("type-aliases", "main.ts", "MyString");
38+
assertSchema("type-aliases-fixed-size-array", "main.ts", "MyFixedSizeArray");
39+
3540
});

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"noLib": false,
1313
"preserveConstEnums": true,
1414
"suppressImplicitAnyIndexErrors": true,
15-
"sourceMap": true
15+
"sourceMap": true,
16+
"watch": false
1617
},
1718
"filesGlob": [
1819
"**/*.ts",

typescript-json-schema.js

Lines changed: 86 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

typescript-json-schema.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)