No msg for missing error response schema for head request

This commit is contained in:
Mike Kistler 2022-11-08 17:06:41 -06:00
Родитель 524f2a059f
Коммит cfab7249a2
2 изменённых файлов: 35 добавлений и 4 удалений

Просмотреть файл

@ -139,10 +139,13 @@ function validateErrorResponse(errorResponse, responsePath) {
// The error response schema should conform to Microsoft API Guidelines
if (!errorResponse.schema) {
errors.push({
message: 'Error response should have a schema.',
path: responsePath,
});
const method = responsePath[responsePath.length - 3];
if (method !== 'head') {
errors.push({
message: 'Error response should have a schema.',
path: responsePath,
});
}
} else {
errors.push(
...validateErrorResponseSchema(errorResponse.schema, [...responsePath, 'schema']),

Просмотреть файл

@ -134,6 +134,34 @@ test('az-error-response should find errors', () => {
});
});
test('az-error-response should not flag missing schema in error response for head method', () => {
const oasDoc = {
swagger: '2.0',
paths: {
'/api/Paths': {
head: {
responses: {
200: {
description: 'Success',
},
default: {
description: 'Error',
headers: {
'x-ms-error-code': {
type: 'string',
},
},
},
},
},
},
},
};
return linter.run(oasDoc).then((results) => {
expect(results.length).toBe(0);
});
});
test('az-error-response should find no errors', () => {
const oasDoc = {
swagger: '2.0',