This commit is contained in:
Mike Kistler 2022-10-28 16:12:18 -05:00
Родитель 4bf665f268
Коммит a630e04cda
4 изменённых файлов: 7786 добавлений и 208 удалений

7929
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -15,9 +15,9 @@
"url": "https://github.com/Azure/azure-api-style-guide"
},
"devDependencies": {
"@stoplight/spectral-core": "1.8.1",
"@stoplight/spectral-ruleset-migrator": "^1.7.1",
"@stoplight/spectral-rulesets": "^1.3.1",
"@stoplight/spectral-core": "^1.15.1",
"@stoplight/spectral-ruleset-migrator": "^1.9.0",
"@stoplight/spectral-rulesets": "^1.14.1",
"ajv": "^8.6.2",
"eslint": "^7.30.0",
"eslint-config-airbnb-base": "^14.2.1",

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

@ -126,31 +126,33 @@ test('az-error-response should find errors', () => {
},
};
return linter.run(oasDoc).then((results) => {
expect(results.length).toBe(12);
expect(results.length).toBe(13);
expect(results[0].path.join('.')).toBe('paths./api/Paths.get.responses.400');
expect(results[0].message).toBe('Error response should contain a x-ms-error-code header.');
expect(results[1].path.join('.')).toBe('paths./api/Paths.get.responses.400.schema');
expect(results[1].message).toBe('Error response schema must be an object schema.');
expect(results[2].path.join('.')).toBe('paths./api/Paths.get.responses.401');
expect(results[2].message).toBe('Error response should contain x-ms-error-response.');
expect(results[3].path.join('.')).toBe('paths./api/Paths.get.responses.401.schema.properties');
expect(results[3].message).toBe('Error response schema should contain an object property named `error`.');
expect(results[4].path.join('.')).toBe('paths./api/Paths.get.responses.403.schema');
expect(results[4].message).toBe('The `error` property in the error response schema should be required.');
expect(results[5].path.join('.')).toBe('paths./api/Paths.get.responses.403.schema.properties.error');
expect(results[5].message).toBe('Error schema should define `code` and `message` properties as required.');
expect(results[6].path.join('.')).toBe('paths./api/Paths.get.responses.409.schema.properties.error.properties');
expect(results[6].message).toBe('Error schema should contain `code` property.');
expect(results[7].path.join('.')).toBe('paths./api/Paths.get.responses.409.schema.properties.error.properties.message');
expect(results[7].message).toBe('The `message` property of error schema should be type `string`.');
expect(results[8].path.join('.')).toBe('paths./api/Paths.get.responses.409.schema.properties.error.required');
expect(results[8].message).toBe('Error schema should define `code` property as required.');
expect(results[9].path.join('.')).toBe('paths./api/Paths.get.responses.412.schema.properties.error.properties');
expect(results[9].message).toBe('Error schema should contain `message` property.');
expect(results[10].path.join('.')).toBe('paths./api/Paths.get.responses.412.schema.properties.error.properties.code.type');
expect(results[10].message).toBe('The `code` property of error schema should be type `string`.');
expect(results[11].path.join('.')).toBe('paths./api/Paths.get.responses.412.schema.properties.error.required');
expect(results[11].message).toBe('Error schema should define `message` property as required.');
expect(results[1].path.join('.')).toBe('paths./api/Paths.get.responses.400');
expect(results[1].message).toBe('Error response should contain x-ms-error-response.');
expect(results[2].path.join('.')).toBe('paths./api/Paths.get.responses.400.schema');
expect(results[2].message).toBe('Error response schema must be an object schema.');
expect(results[3].path.join('.')).toBe('paths./api/Paths.get.responses.401');
expect(results[3].message).toBe('Error response should contain x-ms-error-response.');
expect(results[4].path.join('.')).toBe('paths./api/Paths.get.responses.401.schema.properties');
expect(results[4].message).toBe('Error response schema should contain an object property named `error`.');
expect(results[5].path.join('.')).toBe('paths./api/Paths.get.responses.403.schema');
expect(results[5].message).toBe('The `error` property in the error response schema should be required.');
expect(results[6].path.join('.')).toBe('paths./api/Paths.get.responses.403.schema.properties.error');
expect(results[6].message).toBe('Error schema should define `code` and `message` properties as required.');
expect(results[7].path.join('.')).toBe('paths./api/Paths.get.responses.409.schema.properties.error.properties');
expect(results[7].message).toBe('Error schema should contain `code` property.');
expect(results[8].path.join('.')).toBe('paths./api/Paths.get.responses.409.schema.properties.error.properties.message');
expect(results[8].message).toBe('The `message` property of error schema should be type `string`.');
expect(results[9].path.join('.')).toBe('paths./api/Paths.get.responses.409.schema.properties.error.required');
expect(results[9].message).toBe('Error schema should define `code` property as required.');
expect(results[10].path.join('.')).toBe('paths./api/Paths.get.responses.412.schema.properties.error.properties');
expect(results[10].message).toBe('Error schema should contain `message` property.');
expect(results[11].path.join('.')).toBe('paths./api/Paths.get.responses.412.schema.properties.error.properties.code.type');
expect(results[11].message).toBe('The `code` property of error schema should be type `string`.');
expect(results[12].path.join('.')).toBe('paths./api/Paths.get.responses.412.schema.properties.error.required');
expect(results[12].message).toBe('Error schema should define `message` property as required.');
});
});

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

@ -22,12 +22,13 @@ test('az-operation-id should find operationId not Noun_Verb', () => {
},
};
return linter.run(oasDoc).then((results) => {
expect(results).toHaveLength(2);
expect(results).toHaveLength(3);
expect(results[0].path.join('.')).toBe('paths./api/test1.get.operationId');
expect(results[1].path.join('.')).toBe('paths./api/test1.post.operationId');
results.forEach((result) => expect(result.message).toContain(
'OperationId should be of the form "Noun_Verb"',
));
expect(results[0].message).toBe('OperationId should be of the form "Noun_Verb"');
expect(results[1].path.join('.')).toBe('paths./api/test1.get.operationId');
expect(results[1].message).toBe('OperationId for get method should contain "Get" or "list"');
expect(results[2].path.join('.')).toBe('paths./api/test1.post.operationId');
expect(results[2].message).toBe('OperationId should be of the form "Noun_Verb"');
});
});