@@ -159,6 +159,105 @@ describe('validation plugin - semantic - schema-ibm - Swagger 2', () => {
159
159
expect ( res . warnings . length ) . toEqual ( 0 ) ;
160
160
} ) ;
161
161
162
+ it ( 'should non return an error for a response schema of type file' , ( ) => {
163
+ const config = {
164
+ schemas : {
165
+ invalid_type_format_pair : 'error'
166
+ }
167
+ } ;
168
+
169
+ const spec = {
170
+ paths : {
171
+ '/pets' : {
172
+ get : {
173
+ responses : {
174
+ '200' : {
175
+ description : 'legal response' ,
176
+ schema : {
177
+ type : 'file'
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+ } ;
185
+
186
+ const res = validate ( { jsSpec : spec } , config ) ;
187
+ expect ( res . errors . length ) . toEqual ( 0 ) ;
188
+ expect ( res . warnings . length ) . toEqual ( 0 ) ;
189
+ } ) ;
190
+
191
+ it ( 'should non return an error for a definition with root type of file' , ( ) => {
192
+ const config = {
193
+ schemas : {
194
+ invalid_type_format_pair : 'error'
195
+ }
196
+ } ;
197
+
198
+ const spec = {
199
+ definitions : {
200
+ SomeSchema : {
201
+ type : 'file' ,
202
+ description : 'file schema, used for parameter or response'
203
+ }
204
+ }
205
+ } ;
206
+
207
+ const res = validate ( { jsSpec : spec } , config ) ;
208
+ expect ( res . errors . length ) . toEqual ( 0 ) ;
209
+ expect ( res . warnings . length ) . toEqual ( 0 ) ;
210
+ } ) ;
211
+
212
+ it ( 'should return an error for a response schema with non-root type file' , ( ) => {
213
+ const config = {
214
+ schemas : {
215
+ invalid_type_format_pair : 'error'
216
+ }
217
+ } ;
218
+
219
+ const spec = {
220
+ paths : {
221
+ '/pets' : {
222
+ get : {
223
+ responses : {
224
+ '200' : {
225
+ description : 'legal response' ,
226
+ schema : {
227
+ properties : {
228
+ this_is_bad : {
229
+ type : 'file' ,
230
+ description : 'non-root type of file is bad'
231
+ }
232
+ }
233
+ }
234
+ }
235
+ }
236
+ }
237
+ }
238
+ }
239
+ } ;
240
+
241
+ const res = validate ( { jsSpec : spec } , config ) ;
242
+ expect ( res . errors . length ) . toEqual ( 1 ) ;
243
+ expect ( res . errors [ 0 ] . path ) . toEqual ( [
244
+ 'paths' ,
245
+ '/pets' ,
246
+ 'get' ,
247
+ 'responses' ,
248
+ '200' ,
249
+ 'schema' ,
250
+ 'properties' ,
251
+ 'this_is_bad' ,
252
+ 'type'
253
+ ] ) ;
254
+ expect ( res . errors [ 0 ] . message ) . toEqual (
255
+ 'Property type+format is not well-defined.'
256
+ ) ;
257
+
258
+ expect ( res . warnings . length ) . toEqual ( 0 ) ;
259
+ } ) ;
260
+
162
261
it ( 'should return a warning when a property name is not snake case' , ( ) => {
163
262
const config = {
164
263
schemas : {
@@ -574,7 +673,7 @@ describe('validation plugin - semantic - schema-ibm - OpenAPI 3', () => {
574
673
}
575
674
} ;
576
675
577
- const res = validate ( { jsSpec : spec } , config ) ;
676
+ const res = validate ( { jsSpec : spec , isOAS3 : true } , config ) ;
578
677
expect ( res . errors . length ) . toEqual ( 1 ) ;
579
678
expect ( res . errors [ 0 ] . path ) . toEqual ( [
580
679
'components' ,
@@ -593,6 +692,52 @@ describe('validation plugin - semantic - schema-ibm - OpenAPI 3', () => {
593
692
expect ( res . warnings . length ) . toEqual ( 0 ) ;
594
693
} ) ;
595
694
695
+ it ( 'should return an error for a response schema of type file' , ( ) => {
696
+ const config = {
697
+ schemas : {
698
+ invalid_type_format_pair : 'error'
699
+ }
700
+ } ;
701
+
702
+ const spec = {
703
+ paths : {
704
+ '/pets' : {
705
+ get : {
706
+ responses : {
707
+ '200' : {
708
+ content : {
709
+ 'application/json' : {
710
+ schema : {
711
+ type : 'file'
712
+ }
713
+ }
714
+ }
715
+ }
716
+ }
717
+ }
718
+ }
719
+ }
720
+ } ;
721
+
722
+ const res = validate ( { jsSpec : spec , isOAS3 : true } , config ) ;
723
+ expect ( res . errors . length ) . toEqual ( 1 ) ;
724
+ expect ( res . errors [ 0 ] . path ) . toEqual ( [
725
+ 'paths' ,
726
+ '/pets' ,
727
+ 'get' ,
728
+ 'responses' ,
729
+ '200' ,
730
+ 'content' ,
731
+ 'application/json' ,
732
+ 'schema' ,
733
+ 'type'
734
+ ] ) ;
735
+ expect ( res . errors [ 0 ] . message ) . toEqual (
736
+ 'Property type+format is not well-defined.'
737
+ ) ;
738
+ expect ( res . warnings . length ) . toEqual ( 0 ) ;
739
+ } ) ;
740
+
596
741
it ( 'should not validate an example when it contains the resemblence of a problem' , ( ) => {
597
742
const config = {
598
743
schemas : {
@@ -638,7 +783,7 @@ describe('validation plugin - semantic - schema-ibm - OpenAPI 3', () => {
638
783
}
639
784
} ;
640
785
641
- const res = validate ( { jsSpec : spec } , config ) ;
786
+ const res = validate ( { jsSpec : spec , isOAS3 : true } , config ) ;
642
787
expect ( res . errors . length ) . toEqual ( 1 ) ;
643
788
expect ( res . errors [ 0 ] . path ) . toEqual ( [
644
789
'paths' ,
@@ -704,7 +849,7 @@ describe('validation plugin - semantic - schema-ibm - OpenAPI 3', () => {
704
849
}
705
850
} ;
706
851
707
- const res = validate ( { jsSpec : spec } , config ) ;
852
+ const res = validate ( { jsSpec : spec , isOAS3 : true } , config ) ;
708
853
expect ( res . errors . length ) . toEqual ( 0 ) ;
709
854
expect ( res . warnings . length ) . toEqual ( 1 ) ;
710
855
expect ( res . warnings [ 0 ] . path ) . toEqual ( [
@@ -750,7 +895,7 @@ describe('validation plugin - semantic - schema-ibm - OpenAPI 3', () => {
750
895
}
751
896
} ;
752
897
753
- const res = validate ( { jsSpec : spec } , config ) ;
898
+ const res = validate ( { jsSpec : spec , isOAS3 : true } , config ) ;
754
899
expect ( res . errors . length ) . toEqual ( 0 ) ;
755
900
expect ( res . warnings . length ) . toEqual ( 1 ) ;
756
901
expect ( res . warnings [ 0 ] . path ) . toEqual ( [
0 commit comments