File tree 3 files changed +42
-13
lines changed
test/programs/type-nullable
3 files changed +42
-13
lines changed Original file line number Diff line number Diff line change @@ -16,11 +16,18 @@ type Ref = { foo: number };
16
16
/** @nullable */
17
17
type MyType5 = Ref ;
18
18
19
+ interface MyType6 { } ;
19
20
20
21
interface MyObject {
21
22
var1 : MyType1 ;
22
23
var2 : MyType2 ;
23
24
var3 : MyType3 ;
24
25
var4 : MyType4 ;
25
26
var5 : MyType5 ;
27
+
28
+ /**
29
+ * @nullable
30
+ */
31
+ var6 : MyType6 ;
32
+ var7 : MyType6 ;
26
33
}
Original file line number Diff line number Diff line change 1
1
{
2
- "type" : " object" ,
2
+ "$schema" : " http://json-schema.org/draft-04/schema#" ,
3
+ "definitions" : {
4
+ "MyType6" : {
5
+ "properties" : {
6
+ },
7
+ "type" : " object"
8
+ }
9
+ },
3
10
"properties" : {
4
11
"var1" : {
5
12
"type" : [
17
24
"var3" : {
18
25
"anyOf" : [
19
26
{
20
- "type" : " array" ,
21
27
"items" : {
22
28
"type" : " number"
23
- }
29
+ },
30
+ "type" : " array"
24
31
},
25
32
{
26
33
"type" : " string"
33
40
"var4" : {
34
41
"anyOf" : [
35
42
{
36
- "type" : " array" ,
37
43
"items" : {
38
44
"type" : " number"
39
- }
45
+ },
46
+ "type" : " array"
40
47
},
41
48
{
42
49
"type" : " null"
46
53
"var5" : {
47
54
"anyOf" : [
48
55
{
49
- "type" : " object" ,
50
56
"properties" : {
51
57
"foo" : {
52
58
"type" : " number"
53
59
}
54
60
},
55
61
"required" : [
56
62
" foo"
57
- ]
63
+ ],
64
+ "type" : " object"
58
65
},
59
66
{
60
67
"type" : " null"
61
68
}
62
69
]
70
+ },
71
+ "var6" : {
72
+ "anyOf" : [
73
+ {
74
+ "$ref" : " #/definitions/MyType6"
75
+ },
76
+ {
77
+ "type" : " null"
78
+ }
79
+ ]
80
+ },
81
+ "var7" : {
82
+ "$ref" : " #/definitions/MyType6"
63
83
}
64
84
},
65
85
"required" : [
66
86
" var1" ,
67
87
" var2" ,
68
88
" var3" ,
69
89
" var4" ,
70
- " var5"
90
+ " var5" ,
91
+ " var6" ,
92
+ " var7"
71
93
],
72
- "$schema " : " http://json-schema.org/draft-04/schema# "
73
- }
94
+ "type " : " object "
95
+ }
Original file line number Diff line number Diff line change @@ -619,10 +619,10 @@ export class JsonSchemaGenerator {
619
619
} else {
620
620
this . getClassDefinition ( typ , tc , definition ) ;
621
621
}
622
+ }
622
623
623
- if ( otherAnnotations [ "nullable" ] ) {
624
- this . makeNullable ( definition ) ;
625
- }
624
+ if ( otherAnnotations [ "nullable" ] ) {
625
+ this . makeNullable ( returnedDefinition ) ;
626
626
}
627
627
628
628
return returnedDefinition ;
You can’t perform that action at this time.
0 commit comments