@@ -5,6 +5,8 @@ import { readFileSync } from "fs";
5
5
import { resolve } from "path" ;
6
6
import { versionMajorMinor as typescriptVersionMajorMinor } from "typescript" ;
7
7
import * as TJS from "../typescript-json-schema" ;
8
+ import { JSONPath } from "jsonpath-plus" ;
9
+ import { isEmpty } from "lodash" ;
8
10
9
11
let ajvWarnings : string [ ] = [ ] ;
10
12
const ajv = new Ajv ( {
@@ -47,7 +49,6 @@ export function assertSchema(
47
49
48
50
const files = [ resolve ( BASE + group + "/main.ts" ) ] ;
49
51
const actual = TJS . generateSchema ( TJS . getProgramFromFiles ( files , compilerOptions ) , type , settings , files ) ;
50
-
51
52
// writeFileSync(BASE + group + "/schema.json", stringify(actual, {space: 4}) + "\n\n");
52
53
53
54
const file = readFileSync ( BASE + group + "/schema.json" , "utf8" ) ;
@@ -68,6 +69,13 @@ export function assertSchema(
68
69
ajv . compile ( actual ) ;
69
70
assert . deepEqual ( ajvWarnings , ajvOptions . expectedWarnings || [ ] , "Got unexpected AJV warnings" ) ;
70
71
}
72
+
73
+ const refs :{ $ref : string } [ ] = JSONPath ( { path : "$..[?(@ && @.$ref)]" , json : actual } ) ;
74
+ if ( ! isEmpty ( refs ) ) {
75
+ assert . isTrue ( refs . every ( ( { $ref : r } ) => {
76
+ return ! ( / [ < > , ] / . test ( r ) ) ;
77
+ } ) ) ;
78
+ }
71
79
}
72
80
} ) ;
73
81
}
@@ -282,6 +290,7 @@ describe("schema", () => {
282
290
283
291
describe ( "generics" , ( ) => {
284
292
assertSchema ( "generic-simple" , "MyObject" ) ;
293
+ assertSchema ( "generic-simple-unique" , "MyObject" , { uniqueNames : true } ) ;
285
294
assertSchema ( "generic-arrays" , "MyObject" ) ;
286
295
assertSchema ( "generic-multiple" , "MyObject" ) ;
287
296
assertSchema ( "generic-multiargs" , "MyObject" ) ;
0 commit comments