Skip to content

Commit

Permalink
Merge pull request #20 from cisco-developer/am-update-analyzer-message
Browse files Browse the repository at this point in the history
Remove ref links & update tests
  • Loading branch information
adilmirz authored Aug 11, 2023
2 parents bc5f937 + 021ff36 commit bb3f31b
Show file tree
Hide file tree
Showing 108 changed files with 296 additions and 296 deletions.
48 changes: 24 additions & 24 deletions api-insights-openapi-ruleset.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default {
},
'patch-200-204-success': {
'description': "PATCH operations return either '200 OK' with full representation or '204 No Content'.",
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'given': "$.paths.*[?( @property === 'patch' )]",
'then': {
Expand All @@ -91,7 +91,7 @@ export default {
},
'put-200-204-success': {
'description': "PUT operations return either '200 OK' with full representation or '204 No Content'.",
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'given': '$.paths.*[?( @property === \'put\' )]',
'then': {
Expand Down Expand Up @@ -254,7 +254,7 @@ export default {
},
'date-response-header-requirement': {
'description': "All responses include a 'Date' header in the GMT timezone and RFC 5322 format.",
'message': '{{description}}; {{error}}',
'message': '{{description}}',
'severity': 'error',
'given': '$.paths.*.*.responses[*]',
'then': {
Expand Down Expand Up @@ -352,7 +352,7 @@ export default {
},
'tracking-id-header-requirement': {
'description': "All responses must include a 'TrackingID' header.",
'message': '{{description}}; {{error}}',
'message': '{{description}}',
'severity': 'warn',
'given': '$.paths.*.*.responses[*]',
'then': {
Expand Down Expand Up @@ -561,7 +561,7 @@ export default {
},
'no-crud-verbs': {
'description': 'Standard CRUD lifecycle operations map to HTTP verbs; Functional resources are used when non-standard CRUD are needed.',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'given': '$.paths[*~]',
'then': {
Expand All @@ -570,7 +570,7 @@ export default {
},
'respond-with-recommended-get-codes': {
'description': 'My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'given': "$.paths.*.[?(@property === 'get')].responses.*~",
'then': [
Expand All @@ -584,7 +584,7 @@ export default {
},
'respond-with-recommended-post-codes': {
'description': 'My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'given': "$.paths.*.[?(@property === 'post')].responses.*~",
'then': [
Expand All @@ -598,7 +598,7 @@ export default {
},
'respond-with-recommended-patch-codes': {
'description': 'My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'given': "$.paths.*.[?(@property === 'patch')].responses.*~",
'then': [
Expand All @@ -612,7 +612,7 @@ export default {
},
'respond-with-recommended-put-codes': {
'description': 'My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'given': "$.paths.*.[?(@property === 'put')].responses.*~",
'then': [
Expand All @@ -626,7 +626,7 @@ export default {
},
'respond-with-recommended-delete-codes': {
'description': 'My API responds with recommended HTTP status codes in the 2xx/3xx/4xx/5xx ranges',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'given': "$.paths.*.[?(@property === 'delete')].responses.*~",
'then': [
Expand All @@ -640,7 +640,7 @@ export default {
},
'sort-recommend-order': {
'description': "Consider using 'order' with 'sort' in this operation.",
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'hint',
'given': '$.paths.*.get.parameters',
'then': {
Expand All @@ -649,7 +649,7 @@ export default {
},
'oas2-error-message': {
'description': 'Error representations include a useful human-readable message.',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'formats': [oas2],
'given': "$.paths.*[?(@property != 'head')].responses[?(/^4\\d\\d.*$/i.test(@property) || /^5\\d\\d.*$/i.test(@property))]",
Expand All @@ -661,7 +661,7 @@ export default {
},
'oas3-error-message': {
'description': 'Error representations include a useful human-readable message.',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'formats': [oas3],
'given': "$.paths.*[?(@property != 'head')].responses[?(/^4\\d\\d.*$/i.test(@property) || /^5\\d\\d.*$/i.test(@property))]",
Expand All @@ -673,7 +673,7 @@ export default {
},
'oas2-error-response-identifier': {
'description': 'Error representations include an identifier to help with troubleshooting.',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'warn',
'given': "$.paths.*[?(@property !== 'head')].responses[?(/^4\\d\\d.*$/i.test(@property) || /^5\\d\\d.*$/i.test(@property))]",
'formats': [oas2],
Expand All @@ -685,7 +685,7 @@ export default {
},
'oas3-error-response-identifier': {
'description': 'Error representations include an identifier to help with troubleshooting.',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'warn',
'given': "$.paths.*[?(@property !== 'head')].responses[?(/^4\\d\\d.*$/i.test(@property) || /^5\\d\\d.*$/i.test(@property))]",
'formats': [oas3],
Expand Down Expand Up @@ -1049,7 +1049,7 @@ export default {
},
'oas2-path-based-versioning-error': {
'description': 'API uses path-based versioning.',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'formats': [oas2],
'given': '$',
Expand All @@ -1063,7 +1063,7 @@ export default {
},
'oas3-path-based-versioning-error': {
'description': 'API uses path-based versioning.',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'formats': [oas3],
'given': '$',
Expand All @@ -1089,7 +1089,7 @@ export default {
},
'oas2-path-based-versioning-major-only': {
'description': 'API shows only major version numbers on the path; not the revision numbers.',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'formats': [oas2],
'given': '$',
Expand Down Expand Up @@ -1184,7 +1184,7 @@ export default {
},
'oas2-acceptable-auth': {
'description': 'My API authenticates requests using access tokens; NOT username/passwords.',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'formats': [oas2],
'given': '$.securityDefinitions.*',
Expand All @@ -1194,7 +1194,7 @@ export default {
},
'oas3-acceptable-auth': {
'description': 'My API authenticates requests using access tokens; NOT username/passwords.',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'formats': [oas3],
'given': '$.components.securitySchemes.*',
Expand Down Expand Up @@ -1236,7 +1236,7 @@ export default {
},
'status-code-401': {
'description': 'A 401 status code is returned when authentication fails.',
'message': '{{description}}; {{error}}',
'message': '{{description}}',
'severity': 'error',
'given': '$.paths.*[?(@.security && @.security.length)]',
'then': [
Expand All @@ -1251,7 +1251,7 @@ export default {
},
'status-code-403': {
'description': 'A 403 status code is returned if a consumer is not authorized to access an operation.',
'message': '{{description}}; {{error}}',
'message': '{{description}}',
'severity': 'error',
'given': '$.paths.*[?(@.security && @.security.length)]',
'then': [
Expand Down Expand Up @@ -1305,7 +1305,7 @@ export default {
},
},
'authenticate-requests': {
'description': 'API.REST.SECURITY.03: My API authenticates and authorizes all requests',
'description': 'My API authenticates and authorizes all requests.',
'message': '{{description}}; {{error}}',
'severity': 'error',
'given': '$.paths.*.*',
Expand All @@ -1325,7 +1325,7 @@ export default {
},
'reason-phrase': {
'description': 'Reason phrase needs to match',
'message': '{{description}}; {{error}}',
'message': '{{error}}',
'severity': 'error',
'given': '$.paths.*.*.responses.*.description',
'then': [
Expand Down
4 changes: 2 additions & 2 deletions contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ export default {
},
},
'oas2-meta-info': {
'description': 'Some meta fields must be present',
'message': '{{description}} {{error}}',
'description': 'Some meta fields must be present.',
'message': '{{description}}; {{error}}',
'severity': 'error',
'formats': [oas2],
'type': 'validation',
Expand Down
2 changes: 1 addition & 1 deletion functions/acceptableAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function (input) {
if (invalidScheme) {
return [
{
message: 'My API authenticates requests using access tokens; NOT username/passwords. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'My API authenticates requests using access tokens; NOT username/passwords.',
},
];
}
Expand Down
6 changes: 3 additions & 3 deletions functions/acceptableAuth.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('acceptableAuth', () => {

expect(res).toEqual([
{
message: 'My API authenticates requests using access tokens; NOT username/passwords. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'My API authenticates requests using access tokens; NOT username/passwords.',
},
]);
});
Expand All @@ -68,7 +68,7 @@ describe('acceptableAuth', () => {

expect(res).toEqual([
{
message: 'My API authenticates requests using access tokens; NOT username/passwords. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'My API authenticates requests using access tokens; NOT username/passwords.',
},
]);
});
Expand All @@ -79,7 +79,7 @@ describe('acceptableAuth', () => {

expect(res).toEqual([
{
message: 'My API authenticates requests using access tokens; NOT username/passwords. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'My API authenticates requests using access tokens; NOT username/passwords.',
},
]);
});
Expand Down
4 changes: 2 additions & 2 deletions functions/checkForMaxParameterLinkHeaderLikely.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ const path = [
'/test',
];
const maxQueryMessage = {
message: 'When returning a paginated collection, include a "max" query parameter (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'When returning a paginated collection, include a "max" query parameter',
path: [...path],
};
const linkHeaderMessage = {
message: 'When returning a paginated collection, include a "Link" header in the response (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'When returning a paginated collection, include a "Link" header in the response',
path: [
...path,
'responses',
Expand Down
6 changes: 3 additions & 3 deletions functions/checkForMaxParameterLinkHeaderPossible.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ const path = [
'/test',
];
const maxQueryMessage = {
message: 'When returning a paginated collection, include a "max" query parameter (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'When returning a paginated collection, include a "max" query parameter',
path: [...path],
};
const offsetQueryMessage = {
message: 'When supporting offset-based pagination, operations include a "offset" query parameter (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'When supporting offset-based pagination, operations include a "offset" query parameter',
path: [...path],
};
const linkHeaderMessage = {
message: 'When returning a paginated collection, include a "Link" header in the response (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'When returning a paginated collection, include a "Link" header in the response',
path: [
...path,
'responses',
Expand Down
4 changes: 2 additions & 2 deletions functions/checkPathBasedVersioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function (input, opts) {
if (!(defaultVersioning || paths || onlyMajor)) {
return [
{
message: 'API uses path-based versioning. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'API uses path-based versioning.',
},
];
}
Expand All @@ -60,7 +60,7 @@ export default function (input, opts) {
if ((defaultVersioning || paths) && onlyMajor) {
return [
{
message: 'API shows only major version numbers on the path; not the revision numbers. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'API shows only major version numbers on the path; not the revision numbers.',
},
];
}
Expand Down
4 changes: 2 additions & 2 deletions functions/checkPathBasedVersioning.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
*/

import checkPathBasedVersioning from './checkPathBasedVersioning.js';
const hasVersionErrorMsg = 'API uses path-based versioning. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)';
const onlyMajorErrorMsg = 'API shows only major version numbers on the path; not the revision numbers. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)';
const hasVersionErrorMsg = 'API uses path-based versioning.';
const onlyMajorErrorMsg = 'API shows only major version numbers on the path; not the revision numbers.';

describe('checkPathBasedVersioning', () => {
test('should check version in servers - oas3', () => {
Expand Down
6 changes: 3 additions & 3 deletions functions/checkRFC5322RegexCompliance.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function (input) {
if (!regex.exec(sample)) {
return [
{
message: `The regex pattern used does not pass basic linting sample checks - should have matched case ${ sample } (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `The regex pattern used does not pass basic linting sample checks - should have matched case ${ sample }`,
},
];
}
Expand All @@ -54,15 +54,15 @@ export default function (input) {
if (regex.exec(sample)) {
return [
{
message: `The regex pattern used does not pass basic linting sample checks - should not have matched case ${ sample } (${ msg }) (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `The regex pattern used does not pass basic linting sample checks - should not have matched case ${ sample } (${ msg })`,
},
];
}
}
} catch (err) {
return [
{
message: 'Failed to parse regex (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'Failed to parse regex',
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion functions/checkRFC5322RegexCompliance.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('checkRFC5322RegexCompliance', () => {

expect(res).toEqual([
{
message: 'The regex pattern used does not pass basic linting sample checks - should not have matched case Thu 8 Apr 2021 19:06:27 GMT (Comma required after Day of Week) (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'The regex pattern used does not pass basic linting sample checks - should not have matched case Thu 8 Apr 2021 19:06:27 GMT (Comma required after Day of Week)',
},
]);
});
Expand Down
2 changes: 1 addition & 1 deletion functions/correctResponseRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function (input, opts) {
if (errStatusCodes.length) {
return [
{
message: `Status Code(s) [${ errStatusCodes.toString() }] must be in the ${ rangeString } ranges: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)`,
message: `Status Code(s) [${ errStatusCodes.toString() }] must be in the ${ rangeString } ranges`,
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion functions/correctResponseRange.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('correctResponseRange', () => {

expect(res).toEqual([
{
message: 'Status Code(s) [99,100,782] must be in the 2xx/3xx/4xx/5xx ranges: (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'Status Code(s) [99,100,782] must be in the 2xx/3xx/4xx/5xx ranges',
},
]);
});
Expand Down
2 changes: 1 addition & 1 deletion functions/hasErrorMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function (input, opts, context) {
if (!errorMessage) {
return [
{
message: 'Error representations include a useful human-readable message. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'Error representations include a useful human-readable message.',
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion functions/hasErrorMessage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('hasErrorMessage', () => {

expect(res).toEqual([
{
message: 'Error representations include a useful human-readable message. (https://developer.cisco.com/docs/api-insights/#!api-guidelines-analyzer)',
message: 'Error representations include a useful human-readable message.',
},
]);
});
Expand Down
Loading

0 comments on commit bb3f31b

Please sign in to comment.