Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ testRule('xgen-IPA-005-exception-extension-format', [
errors: [
{
code: 'xgen-IPA-005-exception-extension-format',
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa-spectral#IPA-102',
message: 'IPA exceptions must have a valid rule name and a reason.',
path: ['paths', '/path1', 'x-xgen-IPA-exception'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-005-exception-extension-format',
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa-spectral#IPA-102',
message: 'IPA exceptions must have a valid rule name and a reason.',
path: ['paths', '/path2', 'x-xgen-IPA-exception', 'xgen-IPA-100-rule-name'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-005-exception-extension-format',
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa-spectral#IPA-102',
message: 'IPA exceptions must have a valid rule name and a reason.',
path: ['paths', '/path3', 'x-xgen-IPA-exception', 'invalid-rule-name'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-005-exception-extension-format',
message: 'IPA exceptions must have a valid rule name and a reason. http://go/ipa-spectral#IPA-102',
message: 'IPA exceptions must have a valid rule name and a reason.',
path: ['paths', '/path4', 'x-xgen-IPA-exception', 'xgen-IPA-100-rule-name'],
severity: DiagnosticSeverity.Warning,
},
Expand Down
2 changes: 1 addition & 1 deletion tools/spectral/ipa/__tests__/__helpers__/testRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default (ruleName, tests) => {

errors.forEach((error, index) => {
expect(error.code).toEqual(testCase.errors[index].code);
expect(error.message).toEqual(testCase.errors[index].message);
expect(error.message).toMatch(testCase.errors[index].message);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Why change to match?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use regexp if needed. So basically it is equals when you need equals and regular expression when it is needed. Idea is that we do not need to put lenghtly links in the tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g in future if we change url shortener no one will need to spent +1 hour adjusting test covering the error url

expect(error.path).toEqual(testCase.errors[index].path);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources' is not in camelCase.",
path: ['paths', '/Resources'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -62,7 +62,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'resource_groups' in path '/resource_groups' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'resource_groups' in path '/resource_groups' is not in camelCase.",
path: ['paths', '/resource_groups'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -79,7 +79,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'resource-groups' in path '/resource-groups' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'resource-groups' in path '/resource-groups' is not in camelCase.",
path: ['paths', '/resource-groups'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -96,7 +96,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources:createResource' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources:createResource' is not in camelCase.",
path: ['paths', '/Resources:createResource'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -113,7 +113,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'resourcesAPI' in path '/resourcesAPI' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'resourcesAPI' in path '/resourcesAPI' is not in camelCase.",
path: ['paths', '/resourcesAPI'],
severity: DiagnosticSeverity.Warning,
},
Expand Down Expand Up @@ -145,21 +145,21 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path '/api//users' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path '/api//users' contains double slashes (//) which is not allowed.",
path: ['paths', '/api//users'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path '/resources///{resourceId}' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path '/resources///{resourceId}' contains double slashes (//) which is not allowed.",
path: ['paths', '/resources///{resourceId}'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path '//doubleSlashAtStart' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path '//doubleSlashAtStart' contains double slashes (//) which is not allowed.",
path: ['paths', '//doubleSlashAtStart'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -186,21 +186,21 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'API' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'API' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase.",
path: ['paths', '/API/Resource_groups/{userId}/User-profiles'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Resource_groups' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'Resource_groups' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase.",
path: ['paths', '/API/Resource_groups/{userId}/User-profiles'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'User-profiles' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'User-profiles' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase.",
path: ['paths', '/API/Resource_groups/{userId}/User-profiles'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -217,14 +217,14 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Valid' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'Valid' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase.",
path: ['paths', '/api/Valid/Invalid_resource/{id}:validCustomMethod'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Invalid_resource' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'Invalid_resource' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase.",
path: ['paths', '/api/Valid/Invalid_resource/{id}:validCustomMethod'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -241,14 +241,14 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path '/api//Invalid_segment//resources' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path '/api//Invalid_segment//resources' contains double slashes (//) which is not allowed.",
path: ['paths', '/api//Invalid_segment//resources'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-camelCase',
message:
"Collection identifiers must be in camelCase. Path segment 'Invalid_segment' in path '/api//Invalid_segment//resources' is not in camelCase. http://go/ipa-spectral#IPA-102",
"Collection identifiers must be in camelCase. Path segment 'Invalid_segment' in path '/api//Invalid_segment//resources' is not in camelCase.",
path: ['paths', '/api//Invalid_segment//resources'],
severity: DiagnosticSeverity.Warning,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ testRule('xgen-IPA-102-collection-identifier-pattern', [
{
code: 'xgen-IPA-102-collection-identifier-pattern',
message:
"Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers (/[a-z][a-zA-Z0-9]*/). Path segment 'Resources' in path '/Resources' doesn't match the required pattern. http://go/ipa/102",
"Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers (/[a-z][a-zA-Z0-9]*/). Path segment 'Resources' in path '/Resources' doesn't match the required pattern.",
path: ['paths', '/Resources'],
severity: DiagnosticSeverity.Warning,
},
Expand All @@ -63,14 +63,14 @@ testRule('xgen-IPA-102-collection-identifier-pattern', [
{
code: 'xgen-IPA-102-collection-identifier-pattern',
message:
"Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers (/[a-z][a-zA-Z0-9]*/). Path segment 'resource-groups' in path '/resource-groups' doesn't match the required pattern. http://go/ipa/102",
"Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers (/[a-z][a-zA-Z0-9]*/). Path segment 'resource-groups' in path '/resource-groups' doesn't match the required pattern.",
path: ['paths', '/resource-groups'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-102-collection-identifier-pattern',
message:
"Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers (/[a-z][a-zA-Z0-9]*/). Path segment 'user_profiles' in path '/user_profiles' doesn't match the required pattern. http://go/ipa/102",
"Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers (/[a-z][a-zA-Z0-9]*/). Path segment 'user_profiles' in path '/user_profiles' doesn't match the required pattern.",
path: ['paths', '/user_profiles'],
severity: DiagnosticSeverity.Warning,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,57 +392,50 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [
errors: [
{
code: 'xgen-IPA-106-create-method-request-body-is-get-method-response',
message:
'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106',
message: 'The request body schema properties must match the response body schema properties of the Get method.',
path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-create-method-request-body-is-get-method-response',
message:
'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106',
message: 'The request body schema properties must match the response body schema properties of the Get method.',
path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-create-method-request-body-is-get-method-response',
message:
'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106',
message: 'The request body schema properties must match the response body schema properties of the Get method.',
path: ['paths', '/resourceTwo', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-create-method-request-body-is-get-method-response',
message:
'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106',
message: 'The request body schema properties must match the response body schema properties of the Get method.',
path: ['paths', '/resourceTwo', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-create-method-request-body-is-get-method-response',
message:
'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106',
message: 'The request body schema properties must match the response body schema properties of the Get method.',
path: ['paths', '/resourceThree', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-create-method-request-body-is-get-method-response',
message:
'Could not validate that the Create request body schema matches the response schema of the Get method. The Get method does not have a schema. http://go/ipa-spectral#IPA-106',
'Could not validate that the Create request body schema matches the response schema of the Get method. The Get method does not have a schema.',
path: ['paths', '/resourceFour', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-create-method-request-body-is-get-method-response',
message:
'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106',
message: 'The request body schema properties must match the response body schema properties of the Get method.',
path: ['paths', '/resourceCircular', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-create-method-request-body-is-get-method-response',
message:
'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106',
message: 'The request body schema properties must match the response body schema properties of the Get method.',
path: ['paths', '/resourceCircular', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
Expand Down Expand Up @@ -491,15 +484,13 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [
errors: [
{
code: 'xgen-IPA-106-create-method-request-body-is-get-method-response',
message:
'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106',
message: 'The request body schema properties must match the response body schema properties of the Get method.',
path: ['paths', '/animalResource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
{
code: 'xgen-IPA-106-create-method-request-body-is-get-method-response',
message:
'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106',
message: 'The request body schema properties must match the response body schema properties of the Get method.',
path: ['paths', '/animalResource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'],
severity: DiagnosticSeverity.Warning,
},
Expand Down
Loading
Loading