@@ -3,6 +3,7 @@ import * as stringify from "json-stable-stringify";
3
3
import * as path from "path" ;
4
4
import { createHash } from "crypto" ;
5
5
import * as ts from "typescript" ;
6
+ import { JSONSchema7 } from "json-schema" ;
6
7
export { Program , CompilerOptions , Symbol } from "typescript" ;
7
8
8
9
@@ -65,34 +66,43 @@ export type PartialArgs = Partial<Args>;
65
66
66
67
export type PrimitiveType = number | boolean | string | null ;
67
68
68
- export type Definition = {
69
- $ref ?: string ,
70
- $schema ?: string ,
71
- $id ?: string ,
72
- description ?: string ,
73
- examples ?: any [ ] ,
74
- allOf ?: Definition [ ] ,
75
- oneOf ?: Definition [ ] ,
76
- anyOf ?: Definition [ ] ,
77
- title ?: string ,
78
- type ?: string | string [ ] ,
79
- definitions ?: { [ key : string ] : any } ,
80
- format ?: string ,
81
- items ?: Definition | Definition [ ] ,
82
- minItems ?: number ,
83
- additionalItems ?: {
84
- anyOf : Definition [ ]
85
- } | Definition ,
86
- enum ?: PrimitiveType [ ] | Definition [ ] ,
87
- default ?: PrimitiveType | Object ,
88
- additionalProperties ?: Definition | boolean ,
89
- required ?: string [ ] ,
90
- propertyOrder ?: string [ ] ,
91
- properties ?: { [ key : string ] : any } ,
92
- defaultProperties ?: string [ ] ,
93
- patternProperties ?: { [ pattern : string ] : Definition } ,
94
- typeof ?: "function"
95
- } ;
69
+ type RedifinedFields = "type" | "items" | "additionalItems" | "contains" | "properties" | "patternProperties" | "additionalProperties" | "dependencies" | "propertyNames" | "if" | "then" | "else" | "allOf" | "anyOf" | "oneOf" | "not" | "definitions" ;
70
+ export type DefinitionOrBoolean = Definition | boolean ;
71
+ export interface Definition extends Omit < JSONSchema7 , RedifinedFields > {
72
+ // The type field here is incompatible with the standard definition
73
+ type ?: string | string [ ] ;
74
+
75
+ // Non-standard fields
76
+ propertyOrder ?: string [ ] ;
77
+ defaultProperties ?: string [ ] ;
78
+ typeof ?: "function" ;
79
+
80
+ // Fields that must be redifined because they make use of this definition itself
81
+ items ?: DefinitionOrBoolean | DefinitionOrBoolean [ ] ;
82
+ additionalItems ?: DefinitionOrBoolean ;
83
+ contains ?: JSONSchema7 ;
84
+ properties ?: {
85
+ [ key : string ] : DefinitionOrBoolean ;
86
+ } ;
87
+ patternProperties ?: {
88
+ [ key : string ] : DefinitionOrBoolean ;
89
+ } ;
90
+ additionalProperties ?: DefinitionOrBoolean ;
91
+ dependencies ?: {
92
+ [ key : string ] : DefinitionOrBoolean | string [ ] ;
93
+ } ;
94
+ propertyNames ?: DefinitionOrBoolean ;
95
+ if ?: DefinitionOrBoolean ;
96
+ then ?: DefinitionOrBoolean ;
97
+ else ?: DefinitionOrBoolean ;
98
+ allOf ?: DefinitionOrBoolean [ ] ;
99
+ anyOf ?: DefinitionOrBoolean [ ] ;
100
+ oneOf ?: DefinitionOrBoolean [ ] ;
101
+ not ?: DefinitionOrBoolean ;
102
+ definitions ?: {
103
+ [ key : string ] : DefinitionOrBoolean ;
104
+ } ;
105
+ }
96
106
97
107
export type SymbolRef = {
98
108
name : string ;
0 commit comments