-
Notifications
You must be signed in to change notification settings - Fork 14
CLOUDP 328959: OperationID Validation functions for Create, Delete, and Update methods #805
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 26 commits
cbaf505
eba0010
06d1ca1
f6ff5dd
53692d8
98cc8a1
6360e10
f47ef0a
5e7a26e
1b8e593
ff9eb08
d17c7b6
60197ca
769a4a0
11f4aab
ae54d57
ff7df80
277cb19
bb78336
fcef3e4
50fa6db
5262142
1eee9f3
ecb2e28
3f4fc95
29c55c4
6a9a67d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import testRule from './__helpers__/testRule'; | ||
|
|
||
| // TODO: add tests for xgen-custom-method extension - CLOUDP-306294 | ||
| // TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722 | ||
|
|
||
| const componentSchemas = { | ||
sphterry marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| schemas: { | ||
| Schema: { | ||
| type: 'object', | ||
| }, | ||
| }, | ||
| operationId: 'string', | ||
| }; | ||
|
|
||
| testRule('xgen-IPA-106-valid-operation-id', [ | ||
| { | ||
| name: 'valid methods', | ||
| document: { | ||
| components: componentSchemas, | ||
| paths: { | ||
| '/groups/{groupId}/clusters': { | ||
| post: { | ||
| operationId: 'createGroupCluster', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| errors: [], | ||
| }, | ||
| // This test will be enable when the xgen-IPA-106-valid-operation-id is set to warning severity - CLOUDP-329722 | ||
| /* { | ||
| name: 'invalid methods', | ||
| document: { | ||
| components: componentSchemas, | ||
| paths: { | ||
| '/api/atlas/v2/groups/{groupId}/access': { | ||
| post: { | ||
| operationId: 'addUserToProject', | ||
| }, | ||
| }, | ||
| '/api/atlas/v2/groups/{groupId}/invites': { | ||
| post: { | ||
| operationId: 'createProjectInvitation', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| errors: [ | ||
| { | ||
| code: 'xgen-IPA-106-valid-operation-id', | ||
| message: | ||
| 'Invalid OperationID. The Operation ID must start with the verb “create” and should be followed by a noun or compound noun. The noun(s) in the Operation ID should be the collection identifiers from the resource identifier in singular form. ', | ||
| path: ['paths', '/api/atlas/v2/groups/{groupId}/access', 'post'], | ||
| severity: DiagnosticSeverity.Warning, | ||
| }, | ||
| { | ||
| code: 'xgen-IPA-106-valid-operation-id', | ||
| message: | ||
| 'Invalid OperationID. The Operation ID must start with the verb “create” and should be followed by a noun or compound noun. The noun(s) in the Operation ID should be the collection identifiers from the resource identifier in singular form. ', | ||
| path: ['paths', '/api/atlas/v2/groups/{groupId}/invites', 'post'], | ||
| severity: DiagnosticSeverity.Warning, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just asking to learn: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Severity off still runs the rule but hides the errors, which is what i want here until the package and extension are supported (ie: closer to the time of correction). The rule isn't being tested because it's not active yet, but I have run the tests on error and warning severity and they pass. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perfect! Thanks ❤️ |
||
| }, | ||
| ], | ||
| }, */ | ||
| { | ||
| name: 'invalid methods with exceptions', | ||
| document: { | ||
| components: componentSchemas, | ||
| paths: { | ||
| '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/index ': { | ||
| post: { | ||
| operationId: 'createRollingIndex', | ||
| 'x-xgen-IPA-exception': { | ||
| 'xgen-IPA-106-valid-operation-id': 'Reason', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| errors: [], | ||
| }, | ||
| ]); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import testRule from './__helpers__/testRule'; | ||
| import { DiagnosticSeverity } from '@stoplight/types'; | ||
|
|
||
| // TODO: add tests for xgen-custom-method extension - CLOUDP-306294 | ||
| // TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722 | ||
|
|
||
| const componentSchemas = { | ||
| schemas: { | ||
| Schema: { | ||
| type: 'object', | ||
| }, | ||
| }, | ||
| operationId: 'string', | ||
| }; | ||
|
|
||
| testRule('xgen-IPA-107-valid-operation-id', [ | ||
| { | ||
| name: 'valid methods', | ||
| document: { | ||
| components: componentSchemas, | ||
| paths: { | ||
| 'groups/{groupId}/clusters/{clusterName}': { | ||
| put: { | ||
| operationId: 'updateGroupCluster', | ||
| }, | ||
| }, | ||
| '/groups/{groupId}/settings': { | ||
| put: { | ||
| operationId: 'updateGroupSettings', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| errors: [], | ||
| }, | ||
| // This test will be enable when the xgen-IPA-107-valid-operation-id is set to warning severity - CLOUDP-329722 | ||
| /* { | ||
| name: 'invalid methods', | ||
| document: { | ||
| components: componentSchemas, | ||
| paths: { | ||
| '/api/atlas/v2/groups/{groupId}/limits/{limitName}': { | ||
| patch: { | ||
| operationId: 'setProjectLimit', | ||
| }, | ||
| }, | ||
| '/api/atlas/v2/groups/{groupId}/settings': { | ||
| put: { | ||
| operationId: 'updateProjectSettings', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| errors: [ | ||
| { | ||
| code: 'xgen-IPA-107-valid-operation-id', | ||
| message: | ||
| 'Invalid OperationID. The Operation ID must start with the verb “update” and should be followed by a noun or compound noun. The noun(s) in the Operation ID should be the collection identifiers from the resource identifier in singular form. For singleton resources - the last noun may be in plural form.', | ||
| path: ['paths', '/api/atlas/v2/groups/{groupId}/limits/{limitName}', 'patch'], | ||
| severity: DiagnosticSeverity.Warning, | ||
| }, | ||
| { | ||
| code: 'xgen-IPA-107-valid-operation-id', | ||
| message: | ||
| 'Invalid OperationID. The Operation ID must start with the verb “update” and should be followed by a noun or compound noun. The noun(s) in the Operation ID should be the collection identifiers from the resource identifier in singular form. For singleton resources - the last noun may be in plural form.', | ||
| path: ['paths', '/api/atlas/v2/groups/{groupId}/settings', 'put'], | ||
| severity: DiagnosticSeverity.Warning, | ||
| }, | ||
| ], | ||
| }, */ | ||
| { | ||
| name: 'invalid methods with exceptions', | ||
| document: { | ||
| components: componentSchemas, | ||
| paths: { | ||
| '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/index ': { | ||
| post: { | ||
| operationId: 'updateRollingIndex', | ||
| 'x-xgen-IPA-exception': { | ||
| 'xgen-IPA-107-valid-operation-id': 'Reason', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| errors: [], | ||
| }, | ||
| ]); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| import testRule from './__helpers__/testRule'; | ||
|
|
||
| // TODO: add tests for xgen-custom-method extension - CLOUDP-306294 | ||
| // TOOD: enable tests for invalid methods (after rules are upgraded to warning) - CLOUDP-329722 | ||
|
|
||
| const componentSchemas = { | ||
| schemas: { | ||
| Schema: { | ||
| type: 'object', | ||
| }, | ||
| }, | ||
| operationId: 'string', | ||
| }; | ||
|
|
||
| testRule('xgen-IPA-108-valid-operation-id', [ | ||
| { | ||
| name: 'valid methods', | ||
| document: { | ||
| components: componentSchemas, | ||
| paths: { | ||
| '/groups/{groupId}/clusters/{clusterName}': { | ||
| delete: { | ||
| operationId: 'deleteGroupCluster', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| errors: [], | ||
| }, | ||
| // This test will be enable when the xgen-IPA-108-valid-operation-id is set to warning severity - CLOUDP-329722 | ||
| /* { | ||
| name: 'invalid methods', | ||
| document: { | ||
| components: componentSchemas, | ||
| paths: { | ||
| '/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}': { | ||
| delete: { | ||
| operationId: 'removeProjectApiKey', | ||
| }, | ||
| }, | ||
| '/api/atlas/v2/groups/{groupId}': { | ||
| delete: { | ||
| operationId: 'deleteProject', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| errors: [ | ||
| { | ||
| code: 'xgen-IPA-108-valid-operation-id', | ||
| message: | ||
| 'Invalid OperationID. The Operation ID must start with the verb “delete” and should be followed by a noun or compound noun. The noun(s) in the Operation ID should be the collection identifiers from the resource identifier in singular form. ', | ||
| path: ['paths', '/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}', 'delete'], | ||
| severity: DiagnosticSeverity.Warning, | ||
| }, | ||
| { | ||
| code: 'xgen-IPA-108-valid-operation-id', | ||
| message: | ||
| 'Invalid OperationID. The Operation ID must start with the verb “delete” and should be followed by a noun or compound noun. The noun(s) in the Operation ID should be the collection identifiers from the resource identifier in singular form. ', | ||
| path: ['paths', '/api/atlas/v2/groups/{groupId}', 'delete'], | ||
| severity: DiagnosticSeverity.Warning, | ||
| }, | ||
| ], | ||
| }, */ | ||
| { | ||
| name: 'invalid methods with exceptions', | ||
| document: { | ||
| components: componentSchemas, | ||
| paths: { | ||
| '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/index ': { | ||
| post: { | ||
| operationId: 'deleteRollingIndex', | ||
| 'x-xgen-IPA-exception': { | ||
| 'xgen-IPA-108-valid-operation-id': 'Reason', | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| errors: [], | ||
| }, | ||
| ]); |
Uh oh!
There was an error while loading. Please reload this page.