From 0f463dc98a37990ff03f7270d8c2c08cab6474cd Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 09:53:35 +0100 Subject: [PATCH 01/19] Draft OperationID validation rules --- tools/spectral/ipa/rulesets/IPA-104.yaml | 12 ++++++++++++ tools/spectral/ipa/rulesets/IPA-105.yaml | 19 +++++++++++++++++++ tools/spectral/ipa/rulesets/IPA-106.yaml | 18 ++++++++++++++++++ tools/spectral/ipa/rulesets/IPA-107.yaml | 19 +++++++++++++++++++ tools/spectral/ipa/rulesets/IPA-108.yaml | 18 ++++++++++++++++++ tools/spectral/ipa/rulesets/IPA-109.yaml | 19 +++++++++++++++++++ 6 files changed, 105 insertions(+) diff --git a/tools/spectral/ipa/rulesets/IPA-104.yaml b/tools/spectral/ipa/rulesets/IPA-104.yaml index 2f44419ea6..197874cdd3 100644 --- a/tools/spectral/ipa/rulesets/IPA-104.yaml +++ b/tools/spectral/ipa/rulesets/IPA-104.yaml @@ -8,6 +8,7 @@ functions: - IPA104GetResponseCodeShouldBe200OK - IPA104GetMethodResponseHasNoInputFields - IPA104GetMethodHasNoRequestBody + - IPA104ValidOperationID aliases: GetOperationObject: @@ -97,3 +98,14 @@ rules: given: '#GetOperationObject' then: function: 'IPA104GetMethodHasNoRequestBody' + xgen-IPA-104-valid-operation-id: + description: | + + message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-valid-operation-id' + severity: warn + given: '#GetOperationObject' + then: + function: 'IPA104ValidOperationID' + functionOptions: + methodName: 'get' + prefixes: ['/api'] \ No newline at end of file diff --git a/tools/spectral/ipa/rulesets/IPA-105.yaml b/tools/spectral/ipa/rulesets/IPA-105.yaml index b1f11418e1..097b80072b 100644 --- a/tools/spectral/ipa/rulesets/IPA-105.yaml +++ b/tools/spectral/ipa/rulesets/IPA-105.yaml @@ -6,6 +6,7 @@ functions: - IPA105ListMethodHasNoRequestBody - IPA105EachResourceHasListMethod - IPA105ListMethodResponseIsGetMethodResponse + - IPA105ValidOperationID aliases: GetOperationObject: @@ -77,3 +78,21 @@ rules: then: field: '@key' function: 'IPA105ListMethodResponseIsGetMethodResponse' + xgen-IPA-105-valid-operation-id: + description: | + The Operation ID must start with the verb “list” 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, where the last noun is in plural form. + + ##### Implementation details + Rule checks for the following conditions: + - Applies only to GET methods on resource collection paths + - Ignores singleton resources + - Generates the expected OperationId given the resource identifier + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-valid-operation-id' + severity: warn + given: '#GetOperationObject' + then: + function: 'IPA105ValidOperationID' + functionOptions: + methodName: 'list' diff --git a/tools/spectral/ipa/rulesets/IPA-106.yaml b/tools/spectral/ipa/rulesets/IPA-106.yaml index 5f35d051c3..c14a6167da 100644 --- a/tools/spectral/ipa/rulesets/IPA-106.yaml +++ b/tools/spectral/ipa/rulesets/IPA-106.yaml @@ -8,6 +8,7 @@ functions: - IPA106CreateMethodRequestHasNoReadonlyFields - IPA106CreateMethodResponseCodeIs201Created - IPA106CreateMethodResponseIsGetMethodResponse + - IPA106ValidOperationID aliases: CreateOperationObject: @@ -112,3 +113,20 @@ rules: then: field: '@key' function: 'IPA106CreateMethodResponseIsGetMethodResponse' + xgen-IPA-106-valid-operation-id: + description: | + 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. + + ##### Implementation details + Rule checks for the following conditions: + - Applies only to POST methods on resource collection paths + - Generates the expected OperationId given the resource identifier + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id' + severity: warn + given: '#CreateOperationObject' + then: + function: 'IPA106ValidOperationID' + functionOptions: + methodName: 'create' diff --git a/tools/spectral/ipa/rulesets/IPA-107.yaml b/tools/spectral/ipa/rulesets/IPA-107.yaml index f4eb6994ff..051913c408 100644 --- a/tools/spectral/ipa/rulesets/IPA-107.yaml +++ b/tools/spectral/ipa/rulesets/IPA-107.yaml @@ -8,6 +8,7 @@ functions: - IPA107UpdateMethodRequestHasNoReadonlyFields - IPA107UpdateMethodRequestBodyIsGetResponse - IPA107UpdateMethodRequestBodyIsUpdateRequestSuffixedObject + - IPA107ValidOperationID aliases: UpdateOperationObject: @@ -112,3 +113,21 @@ rules: then: field: '@key' function: 'IPA107UpdateMethodRequestBodyIsUpdateRequestSuffixedObject' + xgen-IPA-107-valid-operation-id: + description: | + 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. + If the resource is a singleton resource, the last noun may be the plural form of the collection identifier. + + ##### Implementation details + Rule checks for the following conditions: + - Validation checks the PATCH/PUT methods for single resource paths and [singleton resources](https://go/ipa/113). + - Generates the expected OperationId given the resource identifier + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-107-valid-operation-id' + severity: warn + given: '#UpdateOperationObject' + then: + function: 'IPA107ValidOperationID' + functionOptions: + methodName: 'update' diff --git a/tools/spectral/ipa/rulesets/IPA-108.yaml b/tools/spectral/ipa/rulesets/IPA-108.yaml index 3084e7f29f..2446017950 100644 --- a/tools/spectral/ipa/rulesets/IPA-108.yaml +++ b/tools/spectral/ipa/rulesets/IPA-108.yaml @@ -55,8 +55,26 @@ rules: given: '#DeleteOperationObject' then: function: IPA108DeleteMethodNoRequestBody + xgen-IPA-108-valid-operation-id: + description: | + 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. + + ##### Implementation details + Rule checks for the following conditions: + - Applies to all DELETE methods for single resource endpoints (with path parameters) + - Generates the expected OperationId given the resource identifier + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-108-valid-operation-id' + severity: warn + given: '#DeleteOperationObject' + then: + function: 'IPA108ValidOperationID' + functionOptions: + methodName: 'delete' functions: - IPA108DeleteMethodResponseShouldNotHaveSchema - IPA108DeleteMethod204Response - IPA108DeleteMethodNoRequestBody + - IPA108ValidOperationID diff --git a/tools/spectral/ipa/rulesets/IPA-109.yaml b/tools/spectral/ipa/rulesets/IPA-109.yaml index 5658b9c88e..c8119ee384 100644 --- a/tools/spectral/ipa/rulesets/IPA-109.yaml +++ b/tools/spectral/ipa/rulesets/IPA-109.yaml @@ -57,3 +57,22 @@ rules: given: '$.paths[*]' then: function: 'IPA109CustomMethodIdentifierFormat' + xgen-IPA-109-valid-operation-id: + description: | + The Operation ID must start with the custom method verb (the custom method path section delimited by the colon (:) character) and should be followed by a noun or compound noun. + If the custom Operation ID has a verb + noun, the Operation ID should end with the noun. + The noun(s) in the Operation ID should be the collection identifiers from the resource identifier. + The noun(s) in the Operation ID should be the collection identifiers from the resource identifier in singular form, where the last noun: + - Is in plural form if the method applies to a collection of resources + - Is in singular form if the method applies to a single resource + + ##### Implementation details + Rule checks for the following conditions: + - Applies only to paths containing custom method identifiers (with colon format) + - Generates the expected OperationId given the resource identifier and the method name portion following the colon + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-109-valid-operation-id' + severity: warn + given: '$.paths[*]' + then: + function: 'IPA109ValidOperationID' From 6658fe1be1bc017c7aa6da49309a69391c5ef00f Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 11:05:15 +0100 Subject: [PATCH 02/19] Update IPA104 opID rule --- tools/spectral/ipa/rulesets/IPA-104.yaml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/spectral/ipa/rulesets/IPA-104.yaml b/tools/spectral/ipa/rulesets/IPA-104.yaml index 197874cdd3..dd9c346433 100644 --- a/tools/spectral/ipa/rulesets/IPA-104.yaml +++ b/tools/spectral/ipa/rulesets/IPA-104.yaml @@ -100,12 +100,19 @@ rules: function: 'IPA104GetMethodHasNoRequestBody' xgen-IPA-104-valid-operation-id: description: | - - message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-valid-operation-id' - severity: warn + The Operation ID must start with the verb “get” 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. + If the resource is a singleton resource, the last noun may be the plural form of the collection identifier. + + ##### Implementation details + Rule checks for the following conditions: + - Applies only to GET methods on single resources or singleton resources + - Generates the expected OperationId given the resource identifier + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-valid-operation-id' + severity: off given: '#GetOperationObject' then: function: 'IPA104ValidOperationID' functionOptions: - methodName: 'get' - prefixes: ['/api'] \ No newline at end of file + methodName: 'get' \ No newline at end of file From ea7edbb9234e3b382c5b0cdc18d22ba8f80fe3ed Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 11:05:35 +0100 Subject: [PATCH 03/19] Update README --- tools/spectral/ipa/rulesets/README.md | 79 +++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 4ebb16eefc..4349ff5aa6 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -139,6 +139,19 @@ Rule checks for the following conditions: - Applies only to GET methods on single resources or singleton resources - Verifies that the operation object does not contain a requestBody property +#### xgen-IPA-104-valid-operation-id + + `off` +The Operation ID must start with the verb “get” 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. +If the resource is a singleton resource, the last noun may be the plural form of the collection identifier. + +##### Implementation details +Rule checks for the following conditions: + - Applies only to GET methods on single resources or singleton resources + - Generates the expected OperationId given the resource identifier + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + ### IPA-105 @@ -193,6 +206,19 @@ The response body of the List method should consist of the same resource object - Fails if the Get method doesn't have a schema reference or if the schemas don't match - Validation ignores resources without a Get method - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation +#### xgen-IPA-105-valid-operation-id + + ![warn](https://img.shields.io/badge/warning-yellow) +The Operation ID must start with the verb “list” 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, where the last noun is in plural form. + +##### Implementation details +Rule checks for the following conditions: + - Applies only to GET methods on resource collection paths + - Ignores singleton resources + - Generates the expected OperationId given the resource identifier + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + ### IPA-106 @@ -273,6 +299,18 @@ Rule checks for the following conditions: - Ignores resources without a Get method - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation +#### xgen-IPA-106-valid-operation-id + + ![warn](https://img.shields.io/badge/warning-yellow) +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. + +##### Implementation details +Rule checks for the following conditions: + - Applies only to POST methods on resource collection paths + - Generates the expected OperationId given the resource identifier + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + ### IPA-107 @@ -344,6 +382,19 @@ Rule checks for the following conditions: - Validation only applies to schema references to a predefined schema (not inline) - Confirms the referenced schema name ends with "Request" suffix +#### xgen-IPA-107-valid-operation-id + + ![warn](https://img.shields.io/badge/warning-yellow) +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. +If the resource is a singleton resource, the last noun may be the plural form of the collection identifier. + +##### Implementation details +Rule checks for the following conditions: + - Validation checks the PATCH/PUT methods for single resource paths and [singleton resources](https://go/ipa/113). + - Generates the expected OperationId given the resource identifier + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + ### IPA-108 @@ -388,6 +439,18 @@ Rule checks for the following conditions: - Fails if any requestBody is defined for the DELETE method - Skips validation for collection endpoints (without path parameters) +#### xgen-IPA-108-valid-operation-id + + ![warn](https://img.shields.io/badge/warning-yellow) +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. + +##### Implementation details +Rule checks for the following conditions: + - Applies to all DELETE methods for single resource endpoints (with path parameters) + - Generates the expected OperationId given the resource identifier + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + ### IPA-109 @@ -433,6 +496,22 @@ Rule checks for the following conditions: - Fails if multiple colons appear in the path - Fails if other than an alphabetical character or a closing curly brace appears before a colon +#### xgen-IPA-109-valid-operation-id + + ![warn](https://img.shields.io/badge/warning-yellow) +The Operation ID must start with the custom method verb (the custom method path section delimited by the colon (:) character) and should be followed by a noun or compound noun. +If the custom Operation ID has a verb + noun, the Operation ID should end with the noun. +The noun(s) in the Operation ID should be the collection identifiers from the resource identifier. +The noun(s) in the Operation ID should be the collection identifiers from the resource identifier in singular form, where the last noun: + - Is in plural form if the method applies to a collection of resources + - Is in singular form if the method applies to a single resource + +##### Implementation details +Rule checks for the following conditions: + - Applies only to paths containing custom method identifiers (with colon format) + - Generates the expected OperationId given the resource identifier and the method name portion following the colon + - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + ### IPA-110 From 427afd7e29049cbb89d466c389b561763ddf1f85 Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 11:55:19 +0100 Subject: [PATCH 04/19] IPA 104 opId tests --- package.json | 3 +- .../__tests__/IPA104ValidOperationID.test.js | 49 +++++++++++-------- tools/spectral/ipa/rulesets/IPA-104.yaml | 2 +- 3 files changed, 31 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 7dceaa4693..789c04e16c 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,7 @@ }, "testPathIgnorePatterns": [ "__helpers__", - "metrics/data", - "IPA\\d+ValidOperationID\\.test\\.js$" + "metrics/data" ] }, "dependencies": { diff --git a/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js index 5794894f5c..6cf163aa79 100644 --- a/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js @@ -1,7 +1,5 @@ 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 +import { DiagnosticSeverity } from '@stoplight/types'; testRule('xgen-IPA-104-valid-operation-id', [ { @@ -17,19 +15,13 @@ testRule('xgen-IPA-104-valid-operation-id', [ }, errors: [], }, - // This test will be enable when the xgen-IPA-104-valid-operation-id is set to warning severity - CLOUDP-329722 - /* { - name: 'invalid methods', + { + name: 'invalid methods with short opIDs', document: { paths: { - '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}/status': { - get: { - operationId: 'getProjectIpAccessListStatus', - }, - }, - '/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}': { + '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}': { get: { - operationId: 'returnFederatedDatabaseQueryLimit', + operationId: 'getProjectIpList', }, }, }, @@ -37,20 +29,37 @@ testRule('xgen-IPA-104-valid-operation-id', [ errors: [ { code: 'xgen-IPA-104-valid-operation-id', - message: - 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}/status', 'get'], + message: 'Invalid OperationID. ', + path: ['paths', '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}', 'get', 'operationId'], severity: DiagnosticSeverity.Warning, }, + ], + }, + { + name: 'invalid methods with long opIDs', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/queryShapeInsights/{queryShapeHash}/details': { + get: { + operationId: 'getShardedClusterBackup', + }, + }, + }, + }, + errors: [ { code: 'xgen-IPA-104-valid-operation-id', - message: - 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}', 'get'], + message: 'Invalid OperationID. ', + path: [ + 'paths', + '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/queryShapeInsights/{queryShapeHash}/details', + 'get', + 'operationId', + ], severity: DiagnosticSeverity.Warning, }, ], - }, */ + }, { name: 'invalid methods with exceptions', document: { diff --git a/tools/spectral/ipa/rulesets/IPA-104.yaml b/tools/spectral/ipa/rulesets/IPA-104.yaml index dd9c346433..caeb7f458c 100644 --- a/tools/spectral/ipa/rulesets/IPA-104.yaml +++ b/tools/spectral/ipa/rulesets/IPA-104.yaml @@ -110,7 +110,7 @@ rules: - Generates the expected OperationId given the resource identifier - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-valid-operation-id' - severity: off + severity: warn given: '#GetOperationObject' then: function: 'IPA104ValidOperationID' From 035946dad56aa07975edbc3a2494665c6976bcaf Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 12:17:00 +0100 Subject: [PATCH 05/19] Enable tests --- .../__tests__/IPA105ValidOperationID.test.js | 27 +++++++------------ .../__tests__/IPA106ValidOperationID.test.js | 15 +++++------ .../__tests__/IPA107ValidOperationID.test.js | 17 +++++------- .../__tests__/IPA108ValidOperationID.test.js | 11 ++++---- 4 files changed, 29 insertions(+), 41 deletions(-) diff --git a/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js index 4b057da052..58a2f5a9e2 100644 --- a/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js @@ -1,7 +1,7 @@ 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 testRule('xgen-IPA-105-valid-operation-id', [ { @@ -17,19 +17,13 @@ testRule('xgen-IPA-105-valid-operation-id', [ }, errors: [], }, - // This test will be enable when the xgen-IPA-105-valid-operation-id is set to warning severity - CLOUDP-329722 - /* { - name: 'invalid methods', + { + name: 'invalid methods with too long opIDs', document: { paths: { - '/api/atlas/v2/orgs/{orgId}/teams/{teamId}/users': { - get: { - operationId: 'listTeamUsers', - }, - }, - '/api/atlas/v2/orgs/{orgId}/events': { + '/api/atlas/v2/unauth/controlPlaneIPAddresses': { get: { - operationId: 'listOrganizationEvents', + operationId: 'returnAllControlPlaneIpAddresses', }, }, }, @@ -37,20 +31,19 @@ testRule('xgen-IPA-105-valid-operation-id', [ errors: [ { code: 'xgen-IPA-105-valid-operation-id', - message: - 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}/databaseUsers/{username}/certs', 'get'], + message: 'Invalid OperationID. ', + path: ['paths', '/api/atlas/v2/unauth/controlPlaneIPAddresses', 'get', 'operationId'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-105-valid-operation-id', message: - 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/orgs/{orgId}/events', 'get'], + "The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. For example: 'listPlaneIPAddresses'. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-valid-operation-id", + path: ['paths', '/api/atlas/v2/unauth/controlPlaneIPAddresses', 'get', 'operationId'], severity: DiagnosticSeverity.Warning, }, ], - }, */ + }, { name: 'invalid methods with exceptions', document: { diff --git a/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js index 717622120c..89b6a18c45 100644 --- a/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js @@ -1,7 +1,7 @@ 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 testRule('xgen-IPA-106-valid-operation-id', [ { @@ -17,8 +17,7 @@ testRule('xgen-IPA-106-valid-operation-id', [ }, 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: { paths: { @@ -38,19 +37,19 @@ testRule('xgen-IPA-106-valid-operation-id', [ { code: 'xgen-IPA-106-valid-operation-id', message: - 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}/access', 'post'], + "Invalid OperationID. Found 'addUserToProject', expected 'createGroupAccess'. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id", + path: ['paths', '/api/atlas/v2/groups/{groupId}/access', 'post', 'operationId'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-valid-operation-id', message: - 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}/invites', 'post'], + "Invalid OperationID. Found 'createProjectInvitation', expected 'createGroupInvite'. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id", + path: ['paths', '/api/atlas/v2/groups/{groupId}/invites', 'post', 'operationId'], severity: DiagnosticSeverity.Warning, }, ], - }, */ + }, { name: 'invalid methods with exceptions', document: { diff --git a/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js index abc58e5fce..67257a9f47 100644 --- a/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js @@ -1,7 +1,7 @@ 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 testRule('xgen-IPA-107-valid-operation-id', [ { @@ -22,8 +22,7 @@ testRule('xgen-IPA-107-valid-operation-id', [ }, 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: { paths: { @@ -42,20 +41,18 @@ testRule('xgen-IPA-107-valid-operation-id', [ errors: [ { code: 'xgen-IPA-107-valid-operation-id', - message: - 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}/limits/{limitName}', 'patch'], + message: 'Invalid OperationID. ', + path: ['paths', '/api/atlas/v2/groups/{groupId}/limits/{limitName}', 'patch', 'operationId'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-107-valid-operation-id', - message: - 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}/settings', 'put'], + message: 'Invalid OperationID. ', + path: ['paths', '/api/atlas/v2/groups/{groupId}/settings', 'put', 'operationId'], severity: DiagnosticSeverity.Warning, }, ], - }, */ + }, { name: 'invalid methods with exceptions', document: { diff --git a/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js index 442da86325..6c46217900 100644 --- a/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js @@ -1,7 +1,7 @@ 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 testRule('xgen-IPA-108-valid-operation-id', [ { @@ -17,8 +17,7 @@ testRule('xgen-IPA-108-valid-operation-id', [ }, 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: { paths: { @@ -38,17 +37,17 @@ testRule('xgen-IPA-108-valid-operation-id', [ { code: 'xgen-IPA-108-valid-operation-id', message: 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}', 'delete'], + path: ['paths', '/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}', 'delete', 'operationId'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-108-valid-operation-id', message: 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}', 'delete'], + path: ['paths', '/api/atlas/v2/groups/{groupId}', 'delete', 'operationId'], severity: DiagnosticSeverity.Warning, }, ], - }, */ + }, { name: 'invalid methods with exceptions', document: { From ca3f2324bdff7e0e1a5b47ed214176ceddd5fa64 Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 13:38:13 +0100 Subject: [PATCH 06/19] Fix IPA104 test with good example --- .../__tests__/IPA104ValidOperationID.test.js | 18 ++++++++++-------- tools/spectral/ipa/rulesets/IPA-104.yaml | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js index 6cf163aa79..2292a1087d 100644 --- a/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js @@ -39,9 +39,9 @@ testRule('xgen-IPA-104-valid-operation-id', [ name: 'invalid methods with long opIDs', document: { paths: { - '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/queryShapeInsights/{queryShapeHash}/details': { + '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs': { get: { - operationId: 'getShardedClusterBackup', + operationId: 'listAlertConfigurationsByAlertId', }, }, }, @@ -50,12 +50,14 @@ testRule('xgen-IPA-104-valid-operation-id', [ { code: 'xgen-IPA-104-valid-operation-id', message: 'Invalid OperationID. ', - path: [ - 'paths', - '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/queryShapeInsights/{queryShapeHash}/details', - 'get', - 'operationId', - ], + path: ['paths', '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs', 'get', 'operationId'], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-104-valid-operation-id', + message: + "The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ", + path: ['paths', '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs', 'get', 'operationId'], severity: DiagnosticSeverity.Warning, }, ], diff --git a/tools/spectral/ipa/rulesets/IPA-104.yaml b/tools/spectral/ipa/rulesets/IPA-104.yaml index caeb7f458c..dfb40b7047 100644 --- a/tools/spectral/ipa/rulesets/IPA-104.yaml +++ b/tools/spectral/ipa/rulesets/IPA-104.yaml @@ -115,4 +115,4 @@ rules: then: function: 'IPA104ValidOperationID' functionOptions: - methodName: 'get' \ No newline at end of file + methodName: 'get' From 5c5b0d53d924066d0e380e5255dc5768c203d1e2 Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 14:04:21 +0100 Subject: [PATCH 07/19] Update and enable tests --- .../__tests__/IPA105ValidOperationID.test.js | 24 +++++++++-- .../__tests__/IPA106ValidOperationID.test.js | 31 ++++++++++++-- .../__tests__/IPA107ValidOperationID.test.js | 31 ++++++++++++-- .../__tests__/IPA108ValidOperationID.test.js | 41 +++++++++++++++++-- .../__tests__/IPA109ValidOperationID.test.js | 35 ++++++++++------ 5 files changed, 138 insertions(+), 24 deletions(-) diff --git a/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js index 58a2f5a9e2..9571e69d2b 100644 --- a/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js @@ -1,8 +1,6 @@ import testRule from './__helpers__/testRule'; import { DiagnosticSeverity } from '@stoplight/types'; -// TODO: add tests for xgen-custom-method extension - CLOUDP-306294 - testRule('xgen-IPA-105-valid-operation-id', [ { name: 'valid methods', @@ -17,6 +15,26 @@ testRule('xgen-IPA-105-valid-operation-id', [ }, errors: [], }, + { + name: 'invalid methods with short opIDs', + document: { + paths: { + '/api/atlas/v2/unauth/openapi/versions': { + get: { + operationId: 'getApiVersions', + }, + }, + }, + }, + errors: [ + { + code: 'xgen-IPA-105-valid-operation-id', + message: 'Invalid OperationID. ', + path: ['paths', '/api/atlas/v2/unauth/openapi/versions', 'get', 'operationId'], + severity: DiagnosticSeverity.Warning, + }, + ], + }, { name: 'invalid methods with too long opIDs', document: { @@ -38,7 +56,7 @@ testRule('xgen-IPA-105-valid-operation-id', [ { code: 'xgen-IPA-105-valid-operation-id', message: - "The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. For example: 'listPlaneIPAddresses'. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-valid-operation-id", + "The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ", path: ['paths', '/api/atlas/v2/unauth/controlPlaneIPAddresses', 'get', 'operationId'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js index 89b6a18c45..83c51fa768 100644 --- a/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js @@ -1,8 +1,6 @@ import testRule from './__helpers__/testRule'; import { DiagnosticSeverity } from '@stoplight/types'; -// TODO: add tests for xgen-custom-method extension - CLOUDP-306294 - testRule('xgen-IPA-106-valid-operation-id', [ { name: 'valid methods', @@ -18,7 +16,7 @@ testRule('xgen-IPA-106-valid-operation-id', [ errors: [], }, { - name: 'invalid methods', + name: 'invalid methods with short opIds', document: { paths: { '/api/atlas/v2/groups/{groupId}/access': { @@ -50,6 +48,33 @@ testRule('xgen-IPA-106-valid-operation-id', [ }, ], }, + { + name: 'invalid methods with too long opIDs', + document: { + paths: { + '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList': { + post: { + operationId: 'createServiceAccountAccessList', + }, + }, + }, + }, + errors: [ + { + code: 'xgen-IPA-106-valid-operation-id', + message: 'Invalid OperationID. ', + path: ['paths', '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList', 'post', 'operationId'], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-106-valid-operation-id', + message: + "The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ", + path: ['paths', '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList', 'post', 'operationId'], + severity: DiagnosticSeverity.Warning, + }, + ], + }, { name: 'invalid methods with exceptions', document: { diff --git a/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js index 67257a9f47..396fd07414 100644 --- a/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js @@ -1,8 +1,6 @@ import testRule from './__helpers__/testRule'; import { DiagnosticSeverity } from '@stoplight/types'; -// TODO: add tests for xgen-custom-method extension - CLOUDP-306294 - testRule('xgen-IPA-107-valid-operation-id', [ { name: 'valid methods', @@ -23,7 +21,7 @@ testRule('xgen-IPA-107-valid-operation-id', [ errors: [], }, { - name: 'invalid methods', + name: 'invalid methods with short opIds', document: { paths: { '/api/atlas/v2/groups/{groupId}/limits/{limitName}': { @@ -53,6 +51,33 @@ testRule('xgen-IPA-107-valid-operation-id', [ }, ], }, + { + name: 'invalid methods with too long opIDs', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/pushBasedLogExport': { + patch: { + operationId: 'updatePushBasedLogConfiguration', + }, + }, + }, + }, + errors: [ + { + code: 'xgen-IPA-107-valid-operation-id', + message: 'Invalid OperationID. ', + path: ['paths', '/api/atlas/v2/groups/{groupId}/pushBasedLogExport', 'patch', 'operationId'], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-107-valid-operation-id', + message: + "The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ", + path: ['paths', '/api/atlas/v2/groups/{groupId}/pushBasedLogExport', 'patch', 'operationId'], + severity: DiagnosticSeverity.Warning, + }, + ], + }, { name: 'invalid methods with exceptions', document: { diff --git a/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js index 6c46217900..f4b9c3064e 100644 --- a/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js @@ -1,8 +1,6 @@ import testRule from './__helpers__/testRule'; import { DiagnosticSeverity } from '@stoplight/types'; -// TODO: add tests for xgen-custom-method extension - CLOUDP-306294 - testRule('xgen-IPA-108-valid-operation-id', [ { name: 'valid methods', @@ -18,7 +16,7 @@ testRule('xgen-IPA-108-valid-operation-id', [ errors: [], }, { - name: 'invalid methods', + name: 'invalid methods with short opIDs', document: { paths: { '/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}': { @@ -48,6 +46,43 @@ testRule('xgen-IPA-108-valid-operation-id', [ }, ], }, + { + name: 'invalid methods with too long opIDs', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}': { + delete: { + operationId: 'deleteOneDataFederationInstanceQueryLimit', + }, + }, + }, + }, + errors: [ + { + code: 'xgen-IPA-108-valid-operation-id', + message: 'Invalid OperationID. ', + path: [ + 'paths', + '/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}', + 'delete', + 'operationId', + ], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-108-valid-operation-id', + message: + "The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ", + path: [ + 'paths', + '/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}', + 'delete', + 'operationId', + ], + severity: DiagnosticSeverity.Warning, + }, + ], + }, { name: 'invalid methods with exceptions', document: { diff --git a/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js index 378d29fa5b..27265dd005 100644 --- a/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js @@ -1,7 +1,5 @@ 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 +import { DiagnosticSeverity } from '@stoplight/types'; testRule('xgen-IPA-109-valid-operation-id', [ { @@ -22,9 +20,8 @@ testRule('xgen-IPA-109-valid-operation-id', [ }, errors: [], }, - // This test will be enable when the xgen-IPA-109-valid-operation-id is set to warning severity - CLOUDP-329722 - /* { - name: 'invalid methods', + { + name: 'invalid methods with short opIds', document: { paths: { '/api/atlas/v2/groups/{groupId}/clusters:search': { @@ -32,6 +29,21 @@ testRule('xgen-IPA-109-valid-operation-id', [ operationId: 'searchClusters', }, }, + }, + }, + errors: [ + { + code: 'xgen-IPA-109-valid-operation-id', + message: 'Invalid OperationID. ', + path: ['paths', '/api/atlas/v2/groups/{groupId}/clusters:search', 'post', 'operationId'], + severity: DiagnosticSeverity.Warning, + }, + ], + }, + { + name: 'invalid methods with too long opIDs', + document: { + paths: { '/api/atlas/v2/groups/{groupId}:migrate': { post: { operationId: 'migrateProjectToAnotherOrg', @@ -42,20 +54,19 @@ testRule('xgen-IPA-109-valid-operation-id', [ errors: [ { code: 'xgen-IPA-109-valid-operation-id', - message: - 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}/clusters:search'], + message: 'Invalid OperationID. ', + path: ['paths', '/api/atlas/v2/groups/{groupId}:migrate', 'post', 'operationId'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-109-valid-operation-id', message: - 'Invalid OperationID. ', - path: ['paths', '/api/atlas/v2/groups/{groupId}:migrate'], + "The Operation ID is longer than 4 words. Please add an 'x-xgen-operation-id-override' extension to the operation with a shorter operation ID. ", + path: ['paths', '/api/atlas/v2/groups/{groupId}:migrate', 'post', 'operationId'], severity: DiagnosticSeverity.Warning, }, ], - }, */ + }, { name: 'invalid methods with exceptions', document: { From f6d19743b23f17cfafba6b658a9feb9642150b1e Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 14:05:35 +0100 Subject: [PATCH 08/19] Update to custom method and docs --- tools/spectral/ipa/rulesets/IPA-109.yaml | 2 +- tools/spectral/ipa/rulesets/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/spectral/ipa/rulesets/IPA-109.yaml b/tools/spectral/ipa/rulesets/IPA-109.yaml index c8119ee384..d6f1fc8315 100644 --- a/tools/spectral/ipa/rulesets/IPA-109.yaml +++ b/tools/spectral/ipa/rulesets/IPA-109.yaml @@ -73,6 +73,6 @@ rules: - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-109-valid-operation-id' severity: warn - given: '$.paths[*]' + given: '$.paths[*][*]' then: function: 'IPA109ValidOperationID' diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 4349ff5aa6..102cb51fee 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -141,7 +141,7 @@ Rule checks for the following conditions: #### xgen-IPA-104-valid-operation-id - `off` + ![warn](https://img.shields.io/badge/warning-yellow) The Operation ID must start with the verb “get” 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. If the resource is a singleton resource, the last noun may be the plural form of the collection identifier. From f89df57a992cbd62305736cdb8c7d07c742425a8 Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 14:06:05 +0100 Subject: [PATCH 09/19] Add type : module to silence error with generateRulesetReadMe parsing --- tools/spectral/ipa/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/spectral/ipa/package.json b/tools/spectral/ipa/package.json index a2ee5943c7..8fc5ff1de1 100644 --- a/tools/spectral/ipa/package.json +++ b/tools/spectral/ipa/package.json @@ -18,6 +18,7 @@ "license": "Apache-2.0", "author": "MongoDB", "main": "ipa-spectral.yaml", + "type": "module", "scripts" : { "gen-ipa-changelog" : "npx auto-changelog" }, From 693f032d08d9de5c0c1620b0cc6dbdd1a9365f4d Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 14:31:05 +0100 Subject: [PATCH 10/19] Refine rule description --- tools/spectral/ipa/rulesets/IPA-104.yaml | 3 +-- tools/spectral/ipa/rulesets/IPA-105.yaml | 3 +-- tools/spectral/ipa/rulesets/IPA-106.yaml | 3 +-- tools/spectral/ipa/rulesets/IPA-107.yaml | 3 +-- tools/spectral/ipa/rulesets/IPA-108.yaml | 3 +-- tools/spectral/ipa/rulesets/IPA-109.yaml | 3 +-- tools/spectral/ipa/rulesets/README.md | 18 ++++++------------ 7 files changed, 12 insertions(+), 24 deletions(-) diff --git a/tools/spectral/ipa/rulesets/IPA-104.yaml b/tools/spectral/ipa/rulesets/IPA-104.yaml index dfb40b7047..fb7783a4dc 100644 --- a/tools/spectral/ipa/rulesets/IPA-104.yaml +++ b/tools/spectral/ipa/rulesets/IPA-104.yaml @@ -107,8 +107,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - Applies only to GET methods on single resources or singleton resources - - Generates the expected OperationId given the resource identifier - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-valid-operation-id' severity: warn given: '#GetOperationObject' diff --git a/tools/spectral/ipa/rulesets/IPA-105.yaml b/tools/spectral/ipa/rulesets/IPA-105.yaml index 097b80072b..d721b3c6b4 100644 --- a/tools/spectral/ipa/rulesets/IPA-105.yaml +++ b/tools/spectral/ipa/rulesets/IPA-105.yaml @@ -87,8 +87,7 @@ rules: Rule checks for the following conditions: - Applies only to GET methods on resource collection paths - Ignores singleton resources - - Generates the expected OperationId given the resource identifier - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-valid-operation-id' severity: warn given: '#GetOperationObject' diff --git a/tools/spectral/ipa/rulesets/IPA-106.yaml b/tools/spectral/ipa/rulesets/IPA-106.yaml index c14a6167da..546ea64286 100644 --- a/tools/spectral/ipa/rulesets/IPA-106.yaml +++ b/tools/spectral/ipa/rulesets/IPA-106.yaml @@ -121,8 +121,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - Applies only to POST methods on resource collection paths - - Generates the expected OperationId given the resource identifier - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id' severity: warn given: '#CreateOperationObject' diff --git a/tools/spectral/ipa/rulesets/IPA-107.yaml b/tools/spectral/ipa/rulesets/IPA-107.yaml index 051913c408..a1415f29cf 100644 --- a/tools/spectral/ipa/rulesets/IPA-107.yaml +++ b/tools/spectral/ipa/rulesets/IPA-107.yaml @@ -122,8 +122,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - Validation checks the PATCH/PUT methods for single resource paths and [singleton resources](https://go/ipa/113). - - Generates the expected OperationId given the resource identifier - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-107-valid-operation-id' severity: warn given: '#UpdateOperationObject' diff --git a/tools/spectral/ipa/rulesets/IPA-108.yaml b/tools/spectral/ipa/rulesets/IPA-108.yaml index 2446017950..a3e8ae7c5e 100644 --- a/tools/spectral/ipa/rulesets/IPA-108.yaml +++ b/tools/spectral/ipa/rulesets/IPA-108.yaml @@ -63,8 +63,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - Applies to all DELETE methods for single resource endpoints (with path parameters) - - Generates the expected OperationId given the resource identifier - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-108-valid-operation-id' severity: warn given: '#DeleteOperationObject' diff --git a/tools/spectral/ipa/rulesets/IPA-109.yaml b/tools/spectral/ipa/rulesets/IPA-109.yaml index d6f1fc8315..e41d434d2a 100644 --- a/tools/spectral/ipa/rulesets/IPA-109.yaml +++ b/tools/spectral/ipa/rulesets/IPA-109.yaml @@ -69,8 +69,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - Applies only to paths containing custom method identifiers (with colon format) - - Generates the expected OperationId given the resource identifier and the method name portion following the colon - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-109-valid-operation-id' severity: warn given: '$.paths[*][*]' diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 102cb51fee..9c29d13524 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -149,8 +149,7 @@ If the resource is a singleton resource, the last noun may be the plural form of ##### Implementation details Rule checks for the following conditions: - Applies only to GET methods on single resources or singleton resources - - Generates the expected OperationId given the resource identifier - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId @@ -216,8 +215,7 @@ The noun(s) in the Operation ID should be the collection identifiers from the re Rule checks for the following conditions: - Applies only to GET methods on resource collection paths - Ignores singleton resources - - Generates the expected OperationId given the resource identifier - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId @@ -308,8 +306,7 @@ The noun(s) in the Operation ID should be the collection identifiers from the re ##### Implementation details Rule checks for the following conditions: - Applies only to POST methods on resource collection paths - - Generates the expected OperationId given the resource identifier - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId @@ -392,8 +389,7 @@ If the resource is a singleton resource, the last noun may be the plural form of ##### Implementation details Rule checks for the following conditions: - Validation checks the PATCH/PUT methods for single resource paths and [singleton resources](https://go/ipa/113). - - Generates the expected OperationId given the resource identifier - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId @@ -448,8 +444,7 @@ The noun(s) in the Operation ID should be the collection identifiers from the re ##### Implementation details Rule checks for the following conditions: - Applies to all DELETE methods for single resource endpoints (with path parameters) - - Generates the expected OperationId given the resource identifier - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId @@ -509,8 +504,7 @@ The noun(s) in the Operation ID should be the collection identifiers from the re ##### Implementation details Rule checks for the following conditions: - Applies only to paths containing custom method identifiers (with colon format) - - Generates the expected OperationId given the resource identifier and the method name portion following the colon - - Confirms that the existing operationId is compliant with generated IPA Compliant OperationId + - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId From a1b66ab4e11108fc9066dc7537b40d723aea2d27 Mon Sep 17 00:00:00 2001 From: Sophia Terry <157913563+sphterry@users.noreply.github.com> Date: Wed, 6 Aug 2025 15:10:05 +0100 Subject: [PATCH 11/19] Apply rule description suggestions Co-authored-by: Lovisa Berggren <59226031+lovisaberggren@users.noreply.github.com> --- tools/spectral/ipa/rulesets/IPA-106.yaml | 2 +- tools/spectral/ipa/rulesets/IPA-107.yaml | 2 +- tools/spectral/ipa/rulesets/IPA-108.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/spectral/ipa/rulesets/IPA-106.yaml b/tools/spectral/ipa/rulesets/IPA-106.yaml index 546ea64286..dafa6ce040 100644 --- a/tools/spectral/ipa/rulesets/IPA-106.yaml +++ b/tools/spectral/ipa/rulesets/IPA-106.yaml @@ -120,7 +120,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - - Applies only to POST methods on resource collection paths + - Applies only to POST methods that are not [custom methods](https://mongodb.github.io/ipa/109) - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id' severity: warn diff --git a/tools/spectral/ipa/rulesets/IPA-107.yaml b/tools/spectral/ipa/rulesets/IPA-107.yaml index a1415f29cf..31fee52af9 100644 --- a/tools/spectral/ipa/rulesets/IPA-107.yaml +++ b/tools/spectral/ipa/rulesets/IPA-107.yaml @@ -121,7 +121,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - - Validation checks the PATCH/PUT methods for single resource paths and [singleton resources](https://go/ipa/113). + - Applies only to PUT/PATCH methods that are not [custom methods](https://mongodb.github.io/ipa/109) - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-107-valid-operation-id' severity: warn diff --git a/tools/spectral/ipa/rulesets/IPA-108.yaml b/tools/spectral/ipa/rulesets/IPA-108.yaml index a3e8ae7c5e..abc11f831b 100644 --- a/tools/spectral/ipa/rulesets/IPA-108.yaml +++ b/tools/spectral/ipa/rulesets/IPA-108.yaml @@ -62,7 +62,7 @@ rules: ##### Implementation details Rule checks for the following conditions: - - Applies to all DELETE methods for single resource endpoints (with path parameters) + - Applies only to DELETE methods that are not [custom methods](https://mongodb.github.io/ipa/109) - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-108-valid-operation-id' severity: warn From 605bda34967bbebca917a158ecd0ffded1305726 Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 15:12:20 +0100 Subject: [PATCH 12/19] update Readme --- tools/spectral/ipa/rulesets/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 9c29d13524..cc5951de30 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -305,7 +305,7 @@ The noun(s) in the Operation ID should be the collection identifiers from the re ##### Implementation details Rule checks for the following conditions: - - Applies only to POST methods on resource collection paths + - Applies only to POST methods that are not [custom methods](https://mongodb.github.io/ipa/109) - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId @@ -388,7 +388,7 @@ If the resource is a singleton resource, the last noun may be the plural form of ##### Implementation details Rule checks for the following conditions: - - Validation checks the PATCH/PUT methods for single resource paths and [singleton resources](https://go/ipa/113). + - Applies only to PUT/PATCH methods that are not [custom methods](https://mongodb.github.io/ipa/109) - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId @@ -443,7 +443,7 @@ The noun(s) in the Operation ID should be the collection identifiers from the re ##### Implementation details Rule checks for the following conditions: - - Applies to all DELETE methods for single resource endpoints (with path parameters) + - Applies only to DELETE methods that are not [custom methods](https://mongodb.github.io/ipa/109) - Confirms that the existing OperationId is compliant with generated IPA Compliant OperationId From d962ed10c870c1172fdeb20a10af5cf8ccb31893 Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 15:23:00 +0100 Subject: [PATCH 13/19] update tests to include expected OperationIds --- .../ipa/__tests__/IPA104ValidOperationID.test.js | 5 +++-- .../ipa/__tests__/IPA105ValidOperationID.test.js | 5 +++-- .../ipa/__tests__/IPA106ValidOperationID.test.js | 9 ++++----- .../ipa/__tests__/IPA107ValidOperationID.test.js | 7 ++++--- .../ipa/__tests__/IPA108ValidOperationID.test.js | 7 ++++--- .../ipa/__tests__/IPA109ValidOperationID.test.js | 4 ++-- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js index 2292a1087d..08307b21be 100644 --- a/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js @@ -29,7 +29,7 @@ testRule('xgen-IPA-104-valid-operation-id', [ errors: [ { code: 'xgen-IPA-104-valid-operation-id', - message: 'Invalid OperationID. ', + message: "Invalid OperationID. Found 'getProjectIpList', expected 'getGroupAccessList'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}/accessList/{entryValue}', 'get', 'operationId'], severity: DiagnosticSeverity.Warning, }, @@ -49,7 +49,8 @@ testRule('xgen-IPA-104-valid-operation-id', [ errors: [ { code: 'xgen-IPA-104-valid-operation-id', - message: 'Invalid OperationID. ', + message: + "Invalid OperationID. Found 'listAlertConfigurationsByAlertId', expected 'getGroupAlertAlertConfigs'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}/alerts/{alertId}/alertConfigs', 'get', 'operationId'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js index 9571e69d2b..357346e0c7 100644 --- a/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js @@ -29,7 +29,7 @@ testRule('xgen-IPA-105-valid-operation-id', [ errors: [ { code: 'xgen-IPA-105-valid-operation-id', - message: 'Invalid OperationID. ', + message: "Invalid OperationID. Found 'getApiVersions', expected 'listOpenapiVersions'. ", path: ['paths', '/api/atlas/v2/unauth/openapi/versions', 'get', 'operationId'], severity: DiagnosticSeverity.Warning, }, @@ -49,7 +49,8 @@ testRule('xgen-IPA-105-valid-operation-id', [ errors: [ { code: 'xgen-IPA-105-valid-operation-id', - message: 'Invalid OperationID. ', + message: + "Invalid OperationID. Found 'returnAllControlPlaneIpAddresses', expected 'listControlPlaneIPAddresses'. ", path: ['paths', '/api/atlas/v2/unauth/controlPlaneIPAddresses', 'get', 'operationId'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js index 83c51fa768..8938d062cc 100644 --- a/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js @@ -34,15 +34,13 @@ testRule('xgen-IPA-106-valid-operation-id', [ errors: [ { code: 'xgen-IPA-106-valid-operation-id', - message: - "Invalid OperationID. Found 'addUserToProject', expected 'createGroupAccess'. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id", + message: "Invalid OperationID. Found 'addUserToProject', expected 'createGroupAccess'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}/access', 'post', 'operationId'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-valid-operation-id', - message: - "Invalid OperationID. Found 'createProjectInvitation', expected 'createGroupInvite'. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-106-valid-operation-id", + message: "Invalid OperationID. Found 'createProjectInvitation', expected 'createGroupInvite'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}/invites', 'post', 'operationId'], severity: DiagnosticSeverity.Warning, }, @@ -62,7 +60,8 @@ testRule('xgen-IPA-106-valid-operation-id', [ errors: [ { code: 'xgen-IPA-106-valid-operation-id', - message: 'Invalid OperationID. ', + message: + "Invalid OperationID. Found 'createServiceAccountAccessList', expected 'createOrgServiceAccountAccessList'. ", path: ['paths', '/api/atlas/v2/orgs/{orgId}/serviceAccounts/{clientId}/accessList', 'post', 'operationId'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js index 396fd07414..547d780746 100644 --- a/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js @@ -39,13 +39,13 @@ testRule('xgen-IPA-107-valid-operation-id', [ errors: [ { code: 'xgen-IPA-107-valid-operation-id', - message: 'Invalid OperationID. ', + message: "Invalid OperationID. Found 'setProjectLimit', expected 'updateGroupLimit'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}/limits/{limitName}', 'patch', 'operationId'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-107-valid-operation-id', - message: 'Invalid OperationID. ', + message: "Invalid OperationID. Found 'updateProjectSettings', expected 'updateGroupSettings'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}/settings', 'put', 'operationId'], severity: DiagnosticSeverity.Warning, }, @@ -65,7 +65,8 @@ testRule('xgen-IPA-107-valid-operation-id', [ errors: [ { code: 'xgen-IPA-107-valid-operation-id', - message: 'Invalid OperationID. ', + message: + "Invalid OperationID. Found 'updatePushBasedLogConfiguration', expected 'updateGroupPushBasedLogExport'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}/pushBasedLogExport', 'patch', 'operationId'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js index f4b9c3064e..c746bad8e8 100644 --- a/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js @@ -34,13 +34,13 @@ testRule('xgen-IPA-108-valid-operation-id', [ errors: [ { code: 'xgen-IPA-108-valid-operation-id', - message: 'Invalid OperationID. ', + message: "Invalid OperationID. Found 'removeProjectApiKey', expected 'deleteGroupApiKey'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}/apiKeys/{apiUserId}', 'delete', 'operationId'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-108-valid-operation-id', - message: 'Invalid OperationID. ', + message: "Invalid OperationID. Found 'deleteProject', expected 'deleteGroup'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}', 'delete', 'operationId'], severity: DiagnosticSeverity.Warning, }, @@ -60,7 +60,8 @@ testRule('xgen-IPA-108-valid-operation-id', [ errors: [ { code: 'xgen-IPA-108-valid-operation-id', - message: 'Invalid OperationID. ', + message: + "Invalid OperationID. Found 'deleteOneDataFederationInstanceQueryLimit', expected 'deleteGroupDataFederationLimit'. ", path: [ 'paths', '/api/atlas/v2/groups/{groupId}/dataFederation/{tenantName}/limits/{limitName}', diff --git a/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js index 27265dd005..c27da9c4e2 100644 --- a/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js @@ -34,7 +34,7 @@ testRule('xgen-IPA-109-valid-operation-id', [ errors: [ { code: 'xgen-IPA-109-valid-operation-id', - message: 'Invalid OperationID. ', + message: "Invalid OperationID. Found 'searchClusters', expected 'searchGroupClusters'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}/clusters:search', 'post', 'operationId'], severity: DiagnosticSeverity.Warning, }, @@ -54,7 +54,7 @@ testRule('xgen-IPA-109-valid-operation-id', [ errors: [ { code: 'xgen-IPA-109-valid-operation-id', - message: 'Invalid OperationID. ', + message: "Invalid OperationID. Found 'migrateProjectToAnotherOrg', expected 'migrateGroup'. ", path: ['paths', '/api/atlas/v2/groups/{groupId}:migrate', 'post', 'operationId'], severity: DiagnosticSeverity.Warning, }, From 4e84ea6f09324b3f8376b31b5ddcb28b8ad628af Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 15:55:24 +0100 Subject: [PATCH 14/19] IPA 104 tests for overrides --- .../__tests__/IPA104ValidOperationID.test.js | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js index 08307b21be..06b6be8f40 100644 --- a/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA104ValidOperationID.test.js @@ -63,6 +63,72 @@ testRule('xgen-IPA-104-valid-operation-id', [ }, ], }, + { + name: 'valid methods with valid overrides', + document: { + paths: { + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}': { + get: { + operationId: 'getFederationSettingConnectedOrgConfigRoleMapping', + 'x-xgen-operation-id-override': 'getRoleMapping', + }, + }, + }, + }, + errors: [], + }, + { + name: 'valid methods with invalid overrides', + document: { + paths: { + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}': { + get: { + operationId: 'getFederationSettingConnectedOrgConfigRoleMapping', + 'x-xgen-operation-id-override': 'getGroupRoleConfig', + }, + }, + }, + }, + errors: [ + { + code: 'xgen-IPA-104-valid-operation-id', + message: + "The operation ID override must only contain nouns from the operation ID 'getFederationSettingConnectedOrgConfigRoleMapping'. ", + path: [ + 'paths', + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}', + 'get', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-104-valid-operation-id', + message: "The operation ID override must end with the noun 'Mapping'. ", + path: [ + 'paths', + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}', + 'get', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + ], + }, + { + name: 'valid method with verb overrides', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/streams/{tenantName}': { + get: { + operationId: 'getGroupStreamWorkspace', + 'x-xgen-method-verb-override': { verb: 'getWorkspace', customMethod: false }, + }, + }, + }, + }, + errors: [], + }, { name: 'invalid methods with exceptions', document: { From 87da16f3a7ac436f35926f8b35dd91eba06bbf7e Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 16:07:56 +0100 Subject: [PATCH 15/19] IPA 105 tests for overrides --- .../__tests__/IPA105ValidOperationID.test.js | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js index 357346e0c7..ec6ad1c05c 100644 --- a/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA105ValidOperationID.test.js @@ -63,6 +63,63 @@ testRule('xgen-IPA-105-valid-operation-id', [ }, ], }, + { + name: 'valid methods with valid overrides', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/backup/exportBuckets': { + get: { + operationId: 'listGroupBackupExportBuckets', + 'x-xgen-operation-id-override': 'listExportBuckets', + }, + }, + }, + }, + errors: [], + }, + { + name: 'valid methods with invalid overrides', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/backup/exportBuckets': { + get: { + operationId: 'listGroupBackupExportBuckets', + 'x-xgen-operation-id-override': 'listMyExports', + }, + }, + }, + }, + errors: [ + { + code: 'xgen-IPA-105-valid-operation-id', + message: + "The operation ID override must only contain nouns from the operation ID 'listGroupBackupExportBuckets'. ", + path: ['paths', '/api/atlas/v2/groups/{groupId}/backup/exportBuckets', 'get', 'x-xgen-operation-id-override'], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-105-valid-operation-id', + message: "The operation ID override must end with the noun 'Buckets'. ", + path: ['paths', '/api/atlas/v2/groups/{groupId}/backup/exportBuckets', 'get', 'x-xgen-operation-id-override'], + severity: DiagnosticSeverity.Warning, + }, + ], + }, + { + name: 'valid method with verb overrides', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/serverless': { + get: { + operationId: 'listGroupServerlessInstances', + 'x-xgen-method-verb-override': { verb: 'listInstances', customMethod: false }, + 'x-xgen-operation-id-override': 'listServerlessInstances', + }, + }, + }, + }, + errors: [], + }, { name: 'invalid methods with exceptions', document: { From 7aa9c17287f682db491ea05c34465c601ddb9b1f Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 16:13:32 +0100 Subject: [PATCH 16/19] IPA 106 tests for overrides --- .../__tests__/IPA106ValidOperationID.test.js | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js index 8938d062cc..5ba1471394 100644 --- a/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA106ValidOperationID.test.js @@ -74,6 +74,84 @@ testRule('xgen-IPA-106-valid-operation-id', [ }, ], }, + { + name: 'valid methods with valid overrides', + document: { + paths: { + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings': { + post: { + operationId: 'createFederationSettingConnectedOrgConfigRoleMapping', + 'x-xgen-operation-id-override': 'createRoleMapping', + }, + }, + }, + }, + errors: [], + }, + { + name: 'valid methods with invalid overrides', + document: { + paths: { + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings': { + post: { + operationId: 'createFederationSettingConnectedOrgConfigRoleMapping', + 'x-xgen-operation-id-override': 'createSettingIDConfigTest', + }, + }, + }, + }, + errors: [ + { + code: 'xgen-IPA-106-valid-operation-id', + message: 'The operation ID override is longer than 4 words. Please shorten it. ', + path: [ + 'paths', + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings', + 'post', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-106-valid-operation-id', + message: + "The operation ID override must only contain nouns from the operation ID 'createFederationSettingConnectedOrgConfigRoleMapping'. ", + path: [ + 'paths', + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings', + 'post', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-106-valid-operation-id', + message: "The operation ID override must end with the noun 'Mapping'. ", + path: [ + 'paths', + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings', + 'post', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + ], + }, + { + name: 'valid method with verb overrides', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/serverless': { + post: { + operationId: 'createGroupServerlessInstance', + 'x-xgen-method-verb-override': { verb: 'createInstance', customMethod: false }, + 'x-xgen-operation-id-override': 'createServerlessInstance', + }, + }, + }, + }, + errors: [], + }, { name: 'invalid methods with exceptions', document: { From d5a2d5cab23c69610ce7f2bba7c36f8f500e8725 Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 16:19:28 +0100 Subject: [PATCH 17/19] IPA 107 tests for overrides --- .../__tests__/IPA107ValidOperationID.test.js | 69 ++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js index 547d780746..5eca9ce856 100644 --- a/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA107ValidOperationID.test.js @@ -79,12 +79,79 @@ testRule('xgen-IPA-107-valid-operation-id', [ }, ], }, + { + name: 'valid methods with valid overrides', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/schedule': { + patch: { + operationId: 'updateGroupClusterBackupSchedule', + 'x-xgen-operation-id-override': 'updateBackupSchedule', + }, + }, + }, + }, + errors: [], + }, + { + name: 'valid methods with invalid overrides', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/schedule': { + patch: { + operationId: 'updateGroupClusterBackupSchedule', + 'x-xgen-operation-id-override': 'updateScheduleBackupMissing', + }, + }, + }, + }, + errors: [ + { + code: 'xgen-IPA-107-valid-operation-id', + message: + "The operation ID override must only contain nouns from the operation ID 'updateGroupClusterBackupSchedule'. ", + path: [ + 'paths', + '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/schedule', + 'patch', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-107-valid-operation-id', + message: "The operation ID override must end with the noun 'Schedule'. ", + path: [ + 'paths', + '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/backup/schedule', + 'patch', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + ], + }, + { + name: 'valid method with verb overrides', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/serverless': { + patch: { + operationId: 'updateGroupServerlessInstance', + 'x-xgen-method-verb-override': { verb: 'updateInstance', customMethod: false }, + 'x-xgen-operation-id-override': 'updateServerlessInstance', + }, + }, + }, + }, + errors: [], + }, { name: 'invalid methods with exceptions', document: { paths: { '/api/atlas/v2/groups/{groupId}/clusters/{clusterName}/index ': { - post: { + put: { operationId: 'updateRollingIndex', 'x-xgen-IPA-exception': { 'xgen-IPA-107-valid-operation-id': 'Reason', From 1bf015f94989b9636aa16f02b30f8f84082e9127 Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 16:25:05 +0100 Subject: [PATCH 18/19] IPA 108 tests for overrides --- .../__tests__/IPA108ValidOperationID.test.js | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js index c746bad8e8..0f193ca39d 100644 --- a/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA108ValidOperationID.test.js @@ -84,6 +84,73 @@ testRule('xgen-IPA-108-valid-operation-id', [ }, ], }, + { + name: 'valid methods with valid overrides', + document: { + paths: { + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}': { + delete: { + operationId: 'deleteFederationSettingConnectedOrgConfigRoleMapping', + 'x-xgen-operation-id-override': 'deleteRoleMapping', + }, + }, + }, + }, + errors: [], + }, + { + name: 'valid methods with invalid overrides', + document: { + paths: { + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}': { + delete: { + operationId: 'deleteFederationSettingConnectedOrgConfigRoleMapping', + 'x-xgen-operation-id-override': 'deleteMappingConfigTest', + }, + }, + }, + }, + errors: [ + { + code: 'xgen-IPA-108-valid-operation-id', + message: + "The operation ID override must only contain nouns from the operation ID 'deleteFederationSettingConnectedOrgConfigRoleMapping'. ", + path: [ + 'paths', + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}', + 'delete', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-108-valid-operation-id', + message: "The operation ID override must end with the noun 'Mapping'. ", + path: [ + 'paths', + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}/roleMappings/{id}', + 'delete', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + ], + }, + { + name: 'valid method with verb overrides', + document: { + paths: { + '/api/atlas/v2/groups/{groupId}/serverless': { + delete: { + operationId: 'deleteGroupServerlessInstance', + 'x-xgen-method-verb-override': { verb: 'deleteInstance', customMethod: false }, + 'x-xgen-operation-id-override': 'deleteServerlessInstance', + }, + }, + }, + }, + errors: [], + }, { name: 'invalid methods with exceptions', document: { From 25b1e3059f67300e97d04039a5c1421e3d9f8087 Mon Sep 17 00:00:00 2001 From: Sophia Marie Terry Date: Wed, 6 Aug 2025 16:31:00 +0100 Subject: [PATCH 19/19] IPA 109 tests for overrides --- .../__tests__/IPA109ValidOperationID.test.js | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js b/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js index c27da9c4e2..bb768016b4 100644 --- a/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js +++ b/tools/spectral/ipa/__tests__/IPA109ValidOperationID.test.js @@ -67,6 +67,60 @@ testRule('xgen-IPA-109-valid-operation-id', [ }, ], }, + { + name: 'valid methods with valid overrides', + document: { + paths: { + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}': { + delete: { + operationId: 'removeFederationSettingConnectedOrgConfig', + 'x-xgen-method-verb-override': { verb: 'remove', customMethod: true }, + 'x-xgen-operation-id-override': 'removeConnectedOrgConfig', + }, + }, + }, + }, + errors: [], + }, + { + name: 'valid methods with invalid overrides', + document: { + paths: { + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}': { + delete: { + operationId: 'removeFederationSettingConnectedOrgConfig', + 'x-xgen-method-verb-override': { verb: 'remove', customMethod: true }, + 'x-xgen-operation-id-override': 'removeOrgConfigTest', + }, + }, + }, + }, + errors: [ + { + code: 'xgen-IPA-109-valid-operation-id', + message: + "The operation ID override must only contain nouns from the operation ID 'removeFederationSettingConnectedOrgConfig'. ", + path: [ + 'paths', + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}', + 'delete', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + { + code: 'xgen-IPA-109-valid-operation-id', + message: "The operation ID override must end with the noun 'Config'. ", + path: [ + 'paths', + '/api/atlas/v2/federationSettings/{federationSettingsId}/connectedOrgConfigs/{orgId}', + 'delete', + 'x-xgen-operation-id-override', + ], + severity: DiagnosticSeverity.Warning, + }, + ], + }, { name: 'invalid methods with exceptions', document: {