@@ -26,7 +26,41 @@ testRule('array-items', [
26
26
} ,
27
27
28
28
{
29
- name : 'array items sibling is present' ,
29
+ name : 'array items sibling is present in a oas2 document' ,
30
+ document : {
31
+ swagger : '2.0' ,
32
+ securityDefinitions : {
33
+ apikey : { } ,
34
+ $ref : '#/securityDefinitions/apikey' ,
35
+ } ,
36
+ paths : {
37
+ $ref : '#/securityDefinitions/apikey' ,
38
+ '/path' : {
39
+ get : {
40
+ '200' : {
41
+ schema : {
42
+ type : 'array' ,
43
+ items : { } ,
44
+ } ,
45
+ } ,
46
+ } ,
47
+ post : {
48
+ '201' : {
49
+ type : 'array' ,
50
+ items : {
51
+ type : 'array' ,
52
+ items : { } ,
53
+ } ,
54
+ } ,
55
+ } ,
56
+ } ,
57
+ } ,
58
+ } ,
59
+ errors : [ ] ,
60
+ } ,
61
+
62
+ {
63
+ name : 'array items sibling is present in oas3 document' ,
30
64
document : {
31
65
$ref : '#/' ,
32
66
responses : {
@@ -46,8 +80,85 @@ testRule('array-items', [
46
80
} ,
47
81
errors : [ ] ,
48
82
} ,
83
+
84
+ {
85
+ name : 'array items sibling is present in oas3.1 document' ,
86
+ document : {
87
+ openapi : '3.1.0' ,
88
+ paths : {
89
+ '/path' : {
90
+ get : {
91
+ responses : {
92
+ '200' : {
93
+ type : 'array' ,
94
+ items : { } ,
95
+ } ,
96
+ } ,
97
+ } ,
98
+ post : {
99
+ responses : {
100
+ '201' : {
101
+ type : 'array' ,
102
+ items : {
103
+ type : 'array' ,
104
+ items : { } ,
105
+ } ,
106
+ } ,
107
+ } ,
108
+ } ,
109
+ } ,
110
+ } ,
111
+ } ,
112
+ errors : [ ] ,
113
+ } ,
114
+
49
115
{
50
- name : 'array items sibling is missing' ,
116
+ name : 'array items sibling is missing in a oas2 document' ,
117
+ document : {
118
+ swagger : '2.0' ,
119
+ securityDefinitions : {
120
+ apikey : { } ,
121
+ $ref : '#/securityDefinitions/apikey' ,
122
+ } ,
123
+ paths : {
124
+ $ref : '#/securityDefinitions/apikey' ,
125
+ '/path' : {
126
+ get : {
127
+ '200' : {
128
+ schema : {
129
+ type : 'array' ,
130
+ } ,
131
+ } ,
132
+ } ,
133
+ post : {
134
+ '201' : {
135
+ type : 'array' ,
136
+ items : {
137
+ type : 'array' ,
138
+ } ,
139
+ } ,
140
+ } ,
141
+ } ,
142
+ } ,
143
+ } ,
144
+ errors : [
145
+ {
146
+ code : 'array-items' ,
147
+ message : 'Schemas with "type: array", require a sibling "items" field' ,
148
+ path : [ 'paths' , '/path' , 'get' , '200' , 'schema' ] ,
149
+ severity : DiagnosticSeverity . Error ,
150
+ } ,
151
+ {
152
+ code : 'array-items' ,
153
+ message : 'Schemas with "type: array", require a sibling "items" field' ,
154
+ path : [ 'paths' , '/path' , 'post' , '201' , 'items' ] ,
155
+ severity : DiagnosticSeverity . Error ,
156
+ } ,
157
+ ] ,
158
+ } ,
159
+
160
+ {
161
+ name : 'array items sibling is missing in oas3 document' ,
51
162
document : {
52
163
$ref : '#/' ,
53
164
responses : {
@@ -78,4 +189,46 @@ testRule('array-items', [
78
189
} ,
79
190
] ,
80
191
} ,
192
+
193
+ {
194
+ name : 'array items sibling is missing in oas3.1 document' ,
195
+ document : {
196
+ openapi : '3.1.0' ,
197
+ paths : {
198
+ '/path' : {
199
+ get : {
200
+ responses : {
201
+ '200' : {
202
+ type : 'array' ,
203
+ } ,
204
+ } ,
205
+ } ,
206
+ post : {
207
+ responses : {
208
+ '201' : {
209
+ type : 'array' ,
210
+ items : {
211
+ type : 'array' ,
212
+ } ,
213
+ } ,
214
+ } ,
215
+ } ,
216
+ } ,
217
+ } ,
218
+ } ,
219
+ errors : [
220
+ {
221
+ code : 'array-items' ,
222
+ message : 'Schemas with "type: array", require a sibling "items" field' ,
223
+ path : [ 'paths' , '/path' , 'get' , 'responses' , '200' ] ,
224
+ severity : DiagnosticSeverity . Error ,
225
+ } ,
226
+ {
227
+ code : 'array-items' ,
228
+ message : 'Schemas with "type: array", require a sibling "items" field' ,
229
+ path : [ 'paths' , '/path' , 'post' , 'responses' , '201' , 'items' ] ,
230
+ severity : DiagnosticSeverity . Error ,
231
+ } ,
232
+ ] ,
233
+ } ,
81
234
] ) ;
0 commit comments