@@ -67,32 +67,29 @@ module.exports.validate = function({ resolvedSpec, isOAS3 }, config) {
67
67
} ) ;
68
68
69
69
// Arrays MUST NOT be returned as the top-level structure in a response body.
70
- const isGetOperation = opKey . toLowerCase ( ) === 'get' ;
71
- if ( isGetOperation ) {
72
- const checkStatus = config . no_array_responses ;
73
- if ( checkStatus !== 'off' ) {
74
- each ( op . responses , ( response , name ) => {
75
- if ( isOAS3 ) {
76
- each ( response . content , ( content , contentType ) => {
77
- if ( content . schema && content . schema . type === 'array' ) {
78
- result [ checkStatus ] . push ( {
79
- path : `paths.${ pathKey } .${ opKey } .responses.${ name } .content.${ contentType } .schema` ,
80
- message :
81
- 'Arrays MUST NOT be returned as the top-level structure in a response body.'
82
- } ) ;
83
- }
84
- } ) ;
85
- } else {
86
- if ( response . schema && response . schema . type === 'array' ) {
87
- result [ checkStatus ] . push ( {
88
- path : `paths.${ pathKey } .${ opKey } .responses.${ name } .schema` ,
70
+ const checkStatusArrRes = config . no_array_responses ;
71
+ if ( checkStatusArrRes !== 'off' ) {
72
+ each ( op . responses , ( response , name ) => {
73
+ if ( isOAS3 ) {
74
+ each ( response . content , ( content , contentType ) => {
75
+ if ( content . schema && content . schema . type === 'array' ) {
76
+ result [ checkStatusArrRes ] . push ( {
77
+ path : `paths.${ pathKey } .${ opKey } .responses.${ name } .content.${ contentType } .schema` ,
89
78
message :
90
79
'Arrays MUST NOT be returned as the top-level structure in a response body.'
91
80
} ) ;
92
81
}
82
+ } ) ;
83
+ } else {
84
+ if ( response . schema && response . schema . type === 'array' ) {
85
+ result [ checkStatusArrRes ] . push ( {
86
+ path : `paths.${ pathKey } .${ opKey } .responses.${ name } .schema` ,
87
+ message :
88
+ 'Arrays MUST NOT be returned as the top-level structure in a response body.'
89
+ } ) ;
93
90
}
94
- } ) ;
95
- }
91
+ }
92
+ } ) ;
96
93
}
97
94
98
95
const hasOperationId =
@@ -153,8 +150,8 @@ module.exports.validate = function({ resolvedSpec, isOAS3 }, config) {
153
150
154
151
// this should be good with resolved spec, but double check
155
152
// All required parameters of an operation are listed before any optional parameters.
156
- const checkStatus = config . parameter_order ;
157
- if ( checkStatus !== 'off' ) {
153
+ const checkStatusParamOrder = config . parameter_order ;
154
+ if ( checkStatusParamOrder !== 'off' ) {
158
155
if ( op . parameters && op . parameters . length > 0 ) {
159
156
let firstOptional = - 1 ;
160
157
for ( let indx = 0 ; indx < op . parameters . length ; indx ++ ) {
@@ -165,7 +162,7 @@ module.exports.validate = function({ resolvedSpec, isOAS3 }, config) {
165
162
}
166
163
} else {
167
164
if ( param . required ) {
168
- result [ checkStatus ] . push ( {
165
+ result [ checkStatusParamOrder ] . push ( {
169
166
path : `paths.${ pathKey } .${ opKey } .parameters[${ indx } ]` ,
170
167
message :
171
168
'Required parameters should appear before optional parameters.'
0 commit comments