Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 42x 8874x 8874x 8874x 8874x 8874x 8874x 8874x | module.exports = (path, isOAS3 = true) => { const operations = [ 'get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace' ]; const pathLength = path.length; // a necessary but not sufficient check for a response object // without these, a schema property named "responses" // may be validated as a response const isResponsesProperty = path[pathLength - 1] === 'responses'; // three scenarios: // 1) inside of an operation const isOperationResponse = operations.includes(path[pathLength - 2]); // 2) inside of components -> responses (oas 3) const isResponseInComponents = pathLength === 2 && path[pathLength - 2] === 'components' && isOAS3; // 3) top level responses (swagger 2) const isTopLevelResponse = pathLength === 1 && !isOAS3; return ( isResponsesProperty && (isOperationResponse || isResponseInComponents || isTopLevelResponse) ); }; |