From 8e6fe2fc710e4e23e4120f0a42e6add4c89581b3 Mon Sep 17 00:00:00 2001 From: wtrocki Date: Fri, 14 Mar 2025 19:49:05 +0100 Subject: [PATCH 1/4] fix: IPA-102 --- ...A102CollectionIdentifierCamelCase.test.js} | 0 ...IPA102CollectionIdentifierPattern.test.js} | 0 ...esBetweenResourceNameAndPathParam.test.js} | 0 tools/spectral/ipa/rulesets/IPA-102.yaml | 36 ++++++++++++++----- tools/spectral/ipa/rulesets/README.md | 19 ++++++++++ ...=> IPA102CollectionIdentifierCamelCase.js} | 0 ...s => IPA102CollectionIdentifierPattern.js} | 0 ...ernatesBetweenResourceNameAndPathParam.js} | 0 .../functions/utils/resourceEvaluation.js | 1 + 9 files changed, 48 insertions(+), 8 deletions(-) rename tools/spectral/ipa/__tests__/{collectionIdentifierCamelCase.test.js => IPA102CollectionIdentifierCamelCase.test.js} (100%) rename tools/spectral/ipa/__tests__/{collectionIdentifierPattern.test.js => IPA102CollectionIdentifierPattern.test.js} (100%) rename tools/spectral/ipa/__tests__/{eachPathAlternatesBetweenResourceNameAndPathParam.test.js => IPA102EachPathAlternatesBetweenResourceNameAndPathParam.test.js} (100%) rename tools/spectral/ipa/rulesets/functions/{collectionIdentifierCamelCase.js => IPA102CollectionIdentifierCamelCase.js} (100%) rename tools/spectral/ipa/rulesets/functions/{collectionIdentifierPattern.js => IPA102CollectionIdentifierPattern.js} (100%) rename tools/spectral/ipa/rulesets/functions/{eachPathAlternatesBetweenResourceNameAndPathParam.js => IPA102EachPathAlternatesBetweenResourceNameAndPathParam.js} (100%) diff --git a/tools/spectral/ipa/__tests__/collectionIdentifierCamelCase.test.js b/tools/spectral/ipa/__tests__/IPA102CollectionIdentifierCamelCase.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/collectionIdentifierCamelCase.test.js rename to tools/spectral/ipa/__tests__/IPA102CollectionIdentifierCamelCase.test.js diff --git a/tools/spectral/ipa/__tests__/collectionIdentifierPattern.test.js b/tools/spectral/ipa/__tests__/IPA102CollectionIdentifierPattern.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/collectionIdentifierPattern.test.js rename to tools/spectral/ipa/__tests__/IPA102CollectionIdentifierPattern.test.js diff --git a/tools/spectral/ipa/__tests__/eachPathAlternatesBetweenResourceNameAndPathParam.test.js b/tools/spectral/ipa/__tests__/IPA102EachPathAlternatesBetweenResourceNameAndPathParam.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/eachPathAlternatesBetweenResourceNameAndPathParam.test.js rename to tools/spectral/ipa/__tests__/IPA102EachPathAlternatesBetweenResourceNameAndPathParam.test.js diff --git a/tools/spectral/ipa/rulesets/IPA-102.yaml b/tools/spectral/ipa/rulesets/IPA-102.yaml index b5b860e3cb..a02018e8d1 100644 --- a/tools/spectral/ipa/rulesets/IPA-102.yaml +++ b/tools/spectral/ipa/rulesets/IPA-102.yaml @@ -22,30 +22,50 @@ rules: given: $.paths then: field: '@key' - function: collectionIdentifierCamelCase + function: IPA102CollectionIdentifierCamelCase functionOptions: # Contains list of ignored path params ignoredValues: ['v2', 'v1'] xgen-IPA-102-path-alternate-resource-name-path-param: - description: 'Paths should alternate between resource names and path params.' + description: | + Paths should alternate between resource names and path params. + + ##### Implementation details + Rule checks for the following conditions: + + - Paths must follow a pattern where resource names and path parameters strictly alternate + - Even-indexed path segments should be resource names (not path parameters) + - Odd-indexed path segments should be path parameters + - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-102-path-alternate-resource-name-path-param' severity: error given: '$.paths' then: field: '@key' - function: 'eachPathAlternatesBetweenResourceNameAndPathParam' + function: IPA102EachPathAlternatesBetweenResourceNameAndPathParam xgen-IPA-102-collection-identifier-pattern: - description: Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. + description: | + Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. + + ##### Implementation details + Rule checks for the following conditions: + + - All path segments that are not path parameters must match pattern `/^[a-z][a-zA-Z0-9]*$/` + - Path parameters (inside curly braces) are excluded from validation + - Custom methods (segments containing colons) are excluded from validation + - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation + - Each non-parameter path segment must start with a lowercase letter followed by any combination of ASCII letters and numbers + message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-102-collection-identifier-pattern' severity: warn given: $.paths then: field: '@key' - function: collectionIdentifierPattern + function: IPA102CollectionIdentifierPattern functions: - - collectionIdentifierPattern - - eachPathAlternatesBetweenResourceNameAndPathParam - - collectionIdentifierCamelCase + - IPA102CollectionIdentifierPattern + - IPA102EachPathAlternatesBetweenResourceNameAndPathParam + - IPA102CollectionIdentifierCamelCase diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index d9083a3853..e325a68a4e 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -33,6 +33,15 @@ Rule is based on [http://go/ipa/IPA-102](http://go/ipa/IPA-102). ![error](https://img.shields.io/badge/error-red) Paths should alternate between resource names and path params. + +##### Implementation details +Rule checks for the following conditions: + + - Paths must follow a pattern where resource names and path parameters strictly alternate + - Even-indexed path segments should be resource names (not path parameters) + - Odd-indexed path segments should be path parameters + - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation + #### xgen-IPA-102-collection-identifier-camelCase ![warn](https://img.shields.io/badge/warning-yellow) @@ -54,6 +63,16 @@ Collection identifiers must be in camelCase. ![warn](https://img.shields.io/badge/warning-yellow) Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. +##### Implementation details +Rule checks for the following conditions: + + - All path segments that are not path parameters must match pattern `/^[a-z][a-zA-Z0-9]*$/` + - Path parameters (inside curly braces) are excluded from validation + - Custom methods (segments containing colons) are excluded from validation + - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation + - Each non-parameter path segment must start with a lowercase letter followed by any combination of ASCII letters and numbers + + ### IPA-104 diff --git a/tools/spectral/ipa/rulesets/functions/collectionIdentifierCamelCase.js b/tools/spectral/ipa/rulesets/functions/IPA102CollectionIdentifierCamelCase.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/collectionIdentifierCamelCase.js rename to tools/spectral/ipa/rulesets/functions/IPA102CollectionIdentifierCamelCase.js diff --git a/tools/spectral/ipa/rulesets/functions/collectionIdentifierPattern.js b/tools/spectral/ipa/rulesets/functions/IPA102CollectionIdentifierPattern.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/collectionIdentifierPattern.js rename to tools/spectral/ipa/rulesets/functions/IPA102CollectionIdentifierPattern.js diff --git a/tools/spectral/ipa/rulesets/functions/eachPathAlternatesBetweenResourceNameAndPathParam.js b/tools/spectral/ipa/rulesets/functions/IPA102EachPathAlternatesBetweenResourceNameAndPathParam.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/eachPathAlternatesBetweenResourceNameAndPathParam.js rename to tools/spectral/ipa/rulesets/functions/IPA102EachPathAlternatesBetweenResourceNameAndPathParam.js diff --git a/tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js b/tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js index 98c38d3d8d..9912c9bcc3 100644 --- a/tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js +++ b/tools/spectral/ipa/rulesets/functions/utils/resourceEvaluation.js @@ -159,6 +159,7 @@ function resourceBelongsToSingleParent(resourcePath) { return isPathParam(parentResourceSection); } +// TODO move prefixes to be rule arguments function removePrefix(path) { if (path.startsWith(AUTH_PREFIX)) { return path.slice(AUTH_PREFIX.length); From 236f358704377eea857085593588f31dd8e45350 Mon Sep 17 00:00:00 2001 From: wtrocki Date: Fri, 14 Mar 2025 19:59:05 +0100 Subject: [PATCH 2/4] fix: renamed files --- ...=> IPA104EachResourceHasGetMethod.test.js} | 0 ...> IPA104GetMethodHasNoRequestBody.test.js} | 0 ...GetMethodResponseHasNoInputFields.test.js} | 0 ...thodReturnsResponseSuffixedObject.test.js} | 0 ...104GetMethodReturnsSingleResource.test.js} | 0 ...PA104GetResponseCodeShouldBe200OK.test.js} | 0 ...> IPA105EachResourceHasListMethod.test.js} | 0 ... IPA105ListMethodHasNoRequestBody.test.js} | 0 ...MethodResponseIsGetMethodResponse.test.js} | 0 ...A105ListResponseCodeShouldBe200OK.test.js} | 0 ...ateMethodRequestBodyIsGetResponse.test.js} | 0 ...equestBodyIsRequestSuffixedObject.test.js} | 0 ...eMethodRequestHasNoReadonlyFields.test.js} | 0 ...ateMethodResponseCodeIs201Created.test.js} | 0 ...MethodResponseIsGetMethodResponse.test.js} | 0 ...ethodShouldNotHaveQueryParameters.test.js} | 0 ...pdateMethodMustNotHaveQueryParams.test.js} | 0 ...07UpdateResponseCodeShouldBe200OK.test.js} | 0 ... => IPA108DeleteMethod204Response.test.js} | 0 ... => IPA108DeleteMethod404Response.test.js} | 0 ...> IPA108DeleteMethodNoRequestBody.test.js} | 0 ...MethodResponseShouldNotHaveSchema.test.js} | 0 ...09EachCustomMethodMustBeGetOrPost.test.js} | 0 ...9EachCustomMethodMustUseCamelCase.test.js} | 0 ...test.js => IPA113SingletonHasNoId.test.js} | 0 ...EachEnumValueMustBeUpperSnakeCase.test.js} | 0 tools/spectral/ipa/rulesets/IPA-102.yaml | 8 +++---- tools/spectral/ipa/rulesets/IPA-104.yaml | 24 +++++++++---------- tools/spectral/ipa/rulesets/IPA-105.yaml | 16 ++++++------- tools/spectral/ipa/rulesets/IPA-106.yaml | 24 +++++++++---------- tools/spectral/ipa/rulesets/IPA-107.yaml | 12 +++++----- tools/spectral/ipa/rulesets/IPA-108.yaml | 16 ++++++------- tools/spectral/ipa/rulesets/IPA-109.yaml | 8 +++---- tools/spectral/ipa/rulesets/IPA-113.yaml | 4 ++-- tools/spectral/ipa/rulesets/IPA-123.yaml | 4 ++-- ...d.js => IPA104EachResourceHasGetMethod.js} | 0 ....js => IPA104GetMethodHasNoRequestBody.js} | 0 ...PA104GetMethodResponseHasNoInputFields.js} | 0 ...GetMethodReturnsResponseSuffixedObject.js} | 0 ...> IPA104GetMethodReturnsSingleResource.js} | 0 ... => IPA104GetResponseCodeShouldBe200OK.js} | 0 ....js => IPA105EachResourceHasListMethod.js} | 0 ...js => IPA105ListMethodHasNoRequestBody.js} | 0 ...5ListMethodResponseIsGetMethodResponse.js} | 0 ...=> IPA105ListResponseCodeShouldBe200OK.js} | 0 ...06CreateMethodRequestBodyIsGetResponse.js} | 0 ...thodRequestBodyIsRequestSuffixedObject.js} | 0 ...CreateMethodRequestHasNoReadonlyFields.js} | 0 ...06CreateMethodResponseCodeIs201Created.js} | 0 ...reateMethodResponseIsGetMethodResponse.js} | 0 ...eateMethodShouldNotHaveQueryParameters.js} | 0 ...A107UpdateMethodMustNotHaveQueryParams.js} | 0 ... IPA107UpdateResponseCodeShouldBe200OK.js} | 0 ...se.js => IPA108DeleteMethod204Response.js} | 0 ...se.js => IPA108DeleteMethod404Response.js} | 0 ....js => IPA108DeleteMethodNoRequestBody.js} | 0 ...eleteMethodResponseShouldNotHaveSchema.js} | 0 ... IPA109EachCustomMethodMustBeGetOrPost.js} | 0 ...IPA109EachCustomMethodMustUseCamelCase.js} | 0 ...onHasNoId.js => IPA113SingletonHasNoId.js} | 0 ...PA123EachEnumValueMustBeUpperSnakeCase.js} | 0 61 files changed, 58 insertions(+), 58 deletions(-) rename tools/spectral/ipa/__tests__/{eachResourceHasGetMethod.test.js => IPA104EachResourceHasGetMethod.test.js} (100%) rename tools/spectral/ipa/__tests__/{getMethodHasNoRequestBody.test.js => IPA104GetMethodHasNoRequestBody.test.js} (100%) rename tools/spectral/ipa/__tests__/{getMethodResponseHasNoInputFields.test.js => IPA104GetMethodResponseHasNoInputFields.test.js} (100%) rename tools/spectral/ipa/__tests__/{getMethodReturnsResponseSuffixedObject.test.js => IPA104GetMethodReturnsResponseSuffixedObject.test.js} (100%) rename tools/spectral/ipa/__tests__/{getMethodReturnsSingleResource.test.js => IPA104GetMethodReturnsSingleResource.test.js} (100%) rename tools/spectral/ipa/__tests__/{getResponseCodeShouldBe200OK.test.js => IPA104GetResponseCodeShouldBe200OK.test.js} (100%) rename tools/spectral/ipa/__tests__/{eachResourceHasListMethod.test.js => IPA105EachResourceHasListMethod.test.js} (100%) rename tools/spectral/ipa/__tests__/{listMethodHasNoRequestBody.test.js => IPA105ListMethodHasNoRequestBody.test.js} (100%) rename tools/spectral/ipa/__tests__/{listMethodResponseIsGetMethodResponse.test.js => IPA105ListMethodResponseIsGetMethodResponse.test.js} (100%) rename tools/spectral/ipa/__tests__/{listResponseCodeShouldBe200OK.test.js => IPA105ListResponseCodeShouldBe200OK.test.js} (100%) rename tools/spectral/ipa/__tests__/{createMethodRequestBodyIsGetResponse.test.js => IPA106CreateMethodRequestBodyIsGetResponse.test.js} (100%) rename tools/spectral/ipa/__tests__/{createMethodRequestBodyIsRequestSuffixedObject.test.js => IPA106CreateMethodRequestBodyIsRequestSuffixedObject.test.js} (100%) rename tools/spectral/ipa/__tests__/{createMethodRequestHasNoReadonlyFields.test.js => IPA106CreateMethodRequestHasNoReadonlyFields.test.js} (100%) rename tools/spectral/ipa/__tests__/{createMethodResponseCodeIs201Created.test.js => IPA106CreateMethodResponseCodeIs201Created.test.js} (100%) rename tools/spectral/ipa/__tests__/{createMethodResponseIsGetMethodResponse.test.js => IPA106CreateMethodResponseIsGetMethodResponse.test.js} (100%) rename tools/spectral/ipa/__tests__/{createMethodShouldNotHaveQueryParameters.test.js => IPA106CreateMethodShouldNotHaveQueryParameters.test.js} (100%) rename tools/spectral/ipa/__tests__/{updateMethodMustNotHaveQueryParams.test.js => IPA107UpdateMethodMustNotHaveQueryParams.test.js} (100%) rename tools/spectral/ipa/__tests__/{updateResponseCodeShouldBe200OK.test.js => IPA107UpdateResponseCodeShouldBe200OK.test.js} (100%) rename tools/spectral/ipa/__tests__/{deleteMethod204Response.test.js => IPA108DeleteMethod204Response.test.js} (100%) rename tools/spectral/ipa/__tests__/{deleteMethod404Response.test.js => IPA108DeleteMethod404Response.test.js} (100%) rename tools/spectral/ipa/__tests__/{deleteMethodNoRequestBody.test.js => IPA108DeleteMethodNoRequestBody.test.js} (100%) rename tools/spectral/ipa/__tests__/{deleteMethodResponseShouldNotHaveSchema.test.js => IPA108DeleteMethodResponseShouldNotHaveSchema.test.js} (100%) rename tools/spectral/ipa/__tests__/{eachCustomMethodMustBeGetOrPost.test.js => IPA109EachCustomMethodMustBeGetOrPost.test.js} (100%) rename tools/spectral/ipa/__tests__/{eachCustomMethodMustUseCamelCase.test.js => IPA109EachCustomMethodMustUseCamelCase.test.js} (100%) rename tools/spectral/ipa/__tests__/{singletonHasNoId.test.js => IPA113SingletonHasNoId.test.js} (100%) rename tools/spectral/ipa/__tests__/{eachEnumValueMustBeUpperSnakeCase.test.js => IPA123EachEnumValueMustBeUpperSnakeCase.test.js} (100%) rename tools/spectral/ipa/rulesets/functions/{eachResourceHasGetMethod.js => IPA104EachResourceHasGetMethod.js} (100%) rename tools/spectral/ipa/rulesets/functions/{getMethodHasNoRequestBody.js => IPA104GetMethodHasNoRequestBody.js} (100%) rename tools/spectral/ipa/rulesets/functions/{getMethodResponseHasNoInputFields.js => IPA104GetMethodResponseHasNoInputFields.js} (100%) rename tools/spectral/ipa/rulesets/functions/{getMethodReturnsResponseSuffixedObject.js => IPA104GetMethodReturnsResponseSuffixedObject.js} (100%) rename tools/spectral/ipa/rulesets/functions/{getMethodReturnsSingleResource.js => IPA104GetMethodReturnsSingleResource.js} (100%) rename tools/spectral/ipa/rulesets/functions/{getResponseCodeShouldBe200OK.js => IPA104GetResponseCodeShouldBe200OK.js} (100%) rename tools/spectral/ipa/rulesets/functions/{eachResourceHasListMethod.js => IPA105EachResourceHasListMethod.js} (100%) rename tools/spectral/ipa/rulesets/functions/{listMethodHasNoRequestBody.js => IPA105ListMethodHasNoRequestBody.js} (100%) rename tools/spectral/ipa/rulesets/functions/{listMethodResponseIsGetMethodResponse.js => IPA105ListMethodResponseIsGetMethodResponse.js} (100%) rename tools/spectral/ipa/rulesets/functions/{listResponseCodeShouldBe200OK.js => IPA105ListResponseCodeShouldBe200OK.js} (100%) rename tools/spectral/ipa/rulesets/functions/{createMethodRequestBodyIsGetResponse.js => IPA106CreateMethodRequestBodyIsGetResponse.js} (100%) rename tools/spectral/ipa/rulesets/functions/{createMethodRequestBodyIsRequestSuffixedObject.js => IPA106CreateMethodRequestBodyIsRequestSuffixedObject.js} (100%) rename tools/spectral/ipa/rulesets/functions/{createMethodRequestHasNoReadonlyFields.js => IPA106CreateMethodRequestHasNoReadonlyFields.js} (100%) rename tools/spectral/ipa/rulesets/functions/{createMethodResponseCodeIs201Created.js => IPA106CreateMethodResponseCodeIs201Created.js} (100%) rename tools/spectral/ipa/rulesets/functions/{createMethodResponseIsGetMethodResponse.js => IPA106CreateMethodResponseIsGetMethodResponse.js} (100%) rename tools/spectral/ipa/rulesets/functions/{createMethodShouldNotHaveQueryParameters.js => IPA106CreateMethodShouldNotHaveQueryParameters.js} (100%) rename tools/spectral/ipa/rulesets/functions/{updateMethodMustNotHaveQueryParams.js => IPA107UpdateMethodMustNotHaveQueryParams.js} (100%) rename tools/spectral/ipa/rulesets/functions/{updateResponseCodeShouldBe200OK.js => IPA107UpdateResponseCodeShouldBe200OK.js} (100%) rename tools/spectral/ipa/rulesets/functions/{deleteMethod204Response.js => IPA108DeleteMethod204Response.js} (100%) rename tools/spectral/ipa/rulesets/functions/{deleteMethod404Response.js => IPA108DeleteMethod404Response.js} (100%) rename tools/spectral/ipa/rulesets/functions/{deleteMethodNoRequestBody.js => IPA108DeleteMethodNoRequestBody.js} (100%) rename tools/spectral/ipa/rulesets/functions/{deleteMethodResponseShouldNotHaveSchema.js => IPA108DeleteMethodResponseShouldNotHaveSchema.js} (100%) rename tools/spectral/ipa/rulesets/functions/{eachCustomMethodMustBeGetOrPost.js => IPA109EachCustomMethodMustBeGetOrPost.js} (100%) rename tools/spectral/ipa/rulesets/functions/{eachCustomMethodMustUseCamelCase.js => IPA109EachCustomMethodMustUseCamelCase.js} (100%) rename tools/spectral/ipa/rulesets/functions/{singletonHasNoId.js => IPA113SingletonHasNoId.js} (100%) rename tools/spectral/ipa/rulesets/functions/{eachEnumValueMustBeUpperSnakeCase.js => IPA123EachEnumValueMustBeUpperSnakeCase.js} (100%) diff --git a/tools/spectral/ipa/__tests__/eachResourceHasGetMethod.test.js b/tools/spectral/ipa/__tests__/IPA104EachResourceHasGetMethod.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/eachResourceHasGetMethod.test.js rename to tools/spectral/ipa/__tests__/IPA104EachResourceHasGetMethod.test.js diff --git a/tools/spectral/ipa/__tests__/getMethodHasNoRequestBody.test.js b/tools/spectral/ipa/__tests__/IPA104GetMethodHasNoRequestBody.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/getMethodHasNoRequestBody.test.js rename to tools/spectral/ipa/__tests__/IPA104GetMethodHasNoRequestBody.test.js diff --git a/tools/spectral/ipa/__tests__/getMethodResponseHasNoInputFields.test.js b/tools/spectral/ipa/__tests__/IPA104GetMethodResponseHasNoInputFields.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/getMethodResponseHasNoInputFields.test.js rename to tools/spectral/ipa/__tests__/IPA104GetMethodResponseHasNoInputFields.test.js diff --git a/tools/spectral/ipa/__tests__/getMethodReturnsResponseSuffixedObject.test.js b/tools/spectral/ipa/__tests__/IPA104GetMethodReturnsResponseSuffixedObject.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/getMethodReturnsResponseSuffixedObject.test.js rename to tools/spectral/ipa/__tests__/IPA104GetMethodReturnsResponseSuffixedObject.test.js diff --git a/tools/spectral/ipa/__tests__/getMethodReturnsSingleResource.test.js b/tools/spectral/ipa/__tests__/IPA104GetMethodReturnsSingleResource.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/getMethodReturnsSingleResource.test.js rename to tools/spectral/ipa/__tests__/IPA104GetMethodReturnsSingleResource.test.js diff --git a/tools/spectral/ipa/__tests__/getResponseCodeShouldBe200OK.test.js b/tools/spectral/ipa/__tests__/IPA104GetResponseCodeShouldBe200OK.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/getResponseCodeShouldBe200OK.test.js rename to tools/spectral/ipa/__tests__/IPA104GetResponseCodeShouldBe200OK.test.js diff --git a/tools/spectral/ipa/__tests__/eachResourceHasListMethod.test.js b/tools/spectral/ipa/__tests__/IPA105EachResourceHasListMethod.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/eachResourceHasListMethod.test.js rename to tools/spectral/ipa/__tests__/IPA105EachResourceHasListMethod.test.js diff --git a/tools/spectral/ipa/__tests__/listMethodHasNoRequestBody.test.js b/tools/spectral/ipa/__tests__/IPA105ListMethodHasNoRequestBody.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/listMethodHasNoRequestBody.test.js rename to tools/spectral/ipa/__tests__/IPA105ListMethodHasNoRequestBody.test.js diff --git a/tools/spectral/ipa/__tests__/listMethodResponseIsGetMethodResponse.test.js b/tools/spectral/ipa/__tests__/IPA105ListMethodResponseIsGetMethodResponse.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/listMethodResponseIsGetMethodResponse.test.js rename to tools/spectral/ipa/__tests__/IPA105ListMethodResponseIsGetMethodResponse.test.js diff --git a/tools/spectral/ipa/__tests__/listResponseCodeShouldBe200OK.test.js b/tools/spectral/ipa/__tests__/IPA105ListResponseCodeShouldBe200OK.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/listResponseCodeShouldBe200OK.test.js rename to tools/spectral/ipa/__tests__/IPA105ListResponseCodeShouldBe200OK.test.js diff --git a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js b/tools/spectral/ipa/__tests__/IPA106CreateMethodRequestBodyIsGetResponse.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js rename to tools/spectral/ipa/__tests__/IPA106CreateMethodRequestBodyIsGetResponse.test.js diff --git a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js b/tools/spectral/ipa/__tests__/IPA106CreateMethodRequestBodyIsRequestSuffixedObject.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js rename to tools/spectral/ipa/__tests__/IPA106CreateMethodRequestBodyIsRequestSuffixedObject.test.js diff --git a/tools/spectral/ipa/__tests__/createMethodRequestHasNoReadonlyFields.test.js b/tools/spectral/ipa/__tests__/IPA106CreateMethodRequestHasNoReadonlyFields.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/createMethodRequestHasNoReadonlyFields.test.js rename to tools/spectral/ipa/__tests__/IPA106CreateMethodRequestHasNoReadonlyFields.test.js diff --git a/tools/spectral/ipa/__tests__/createMethodResponseCodeIs201Created.test.js b/tools/spectral/ipa/__tests__/IPA106CreateMethodResponseCodeIs201Created.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/createMethodResponseCodeIs201Created.test.js rename to tools/spectral/ipa/__tests__/IPA106CreateMethodResponseCodeIs201Created.test.js diff --git a/tools/spectral/ipa/__tests__/createMethodResponseIsGetMethodResponse.test.js b/tools/spectral/ipa/__tests__/IPA106CreateMethodResponseIsGetMethodResponse.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/createMethodResponseIsGetMethodResponse.test.js rename to tools/spectral/ipa/__tests__/IPA106CreateMethodResponseIsGetMethodResponse.test.js diff --git a/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js b/tools/spectral/ipa/__tests__/IPA106CreateMethodShouldNotHaveQueryParameters.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js rename to tools/spectral/ipa/__tests__/IPA106CreateMethodShouldNotHaveQueryParameters.test.js diff --git a/tools/spectral/ipa/__tests__/updateMethodMustNotHaveQueryParams.test.js b/tools/spectral/ipa/__tests__/IPA107UpdateMethodMustNotHaveQueryParams.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/updateMethodMustNotHaveQueryParams.test.js rename to tools/spectral/ipa/__tests__/IPA107UpdateMethodMustNotHaveQueryParams.test.js diff --git a/tools/spectral/ipa/__tests__/updateResponseCodeShouldBe200OK.test.js b/tools/spectral/ipa/__tests__/IPA107UpdateResponseCodeShouldBe200OK.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/updateResponseCodeShouldBe200OK.test.js rename to tools/spectral/ipa/__tests__/IPA107UpdateResponseCodeShouldBe200OK.test.js diff --git a/tools/spectral/ipa/__tests__/deleteMethod204Response.test.js b/tools/spectral/ipa/__tests__/IPA108DeleteMethod204Response.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/deleteMethod204Response.test.js rename to tools/spectral/ipa/__tests__/IPA108DeleteMethod204Response.test.js diff --git a/tools/spectral/ipa/__tests__/deleteMethod404Response.test.js b/tools/spectral/ipa/__tests__/IPA108DeleteMethod404Response.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/deleteMethod404Response.test.js rename to tools/spectral/ipa/__tests__/IPA108DeleteMethod404Response.test.js diff --git a/tools/spectral/ipa/__tests__/deleteMethodNoRequestBody.test.js b/tools/spectral/ipa/__tests__/IPA108DeleteMethodNoRequestBody.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/deleteMethodNoRequestBody.test.js rename to tools/spectral/ipa/__tests__/IPA108DeleteMethodNoRequestBody.test.js diff --git a/tools/spectral/ipa/__tests__/deleteMethodResponseShouldNotHaveSchema.test.js b/tools/spectral/ipa/__tests__/IPA108DeleteMethodResponseShouldNotHaveSchema.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/deleteMethodResponseShouldNotHaveSchema.test.js rename to tools/spectral/ipa/__tests__/IPA108DeleteMethodResponseShouldNotHaveSchema.test.js diff --git a/tools/spectral/ipa/__tests__/eachCustomMethodMustBeGetOrPost.test.js b/tools/spectral/ipa/__tests__/IPA109EachCustomMethodMustBeGetOrPost.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/eachCustomMethodMustBeGetOrPost.test.js rename to tools/spectral/ipa/__tests__/IPA109EachCustomMethodMustBeGetOrPost.test.js diff --git a/tools/spectral/ipa/__tests__/eachCustomMethodMustUseCamelCase.test.js b/tools/spectral/ipa/__tests__/IPA109EachCustomMethodMustUseCamelCase.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/eachCustomMethodMustUseCamelCase.test.js rename to tools/spectral/ipa/__tests__/IPA109EachCustomMethodMustUseCamelCase.test.js diff --git a/tools/spectral/ipa/__tests__/singletonHasNoId.test.js b/tools/spectral/ipa/__tests__/IPA113SingletonHasNoId.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/singletonHasNoId.test.js rename to tools/spectral/ipa/__tests__/IPA113SingletonHasNoId.test.js diff --git a/tools/spectral/ipa/__tests__/eachEnumValueMustBeUpperSnakeCase.test.js b/tools/spectral/ipa/__tests__/IPA123EachEnumValueMustBeUpperSnakeCase.test.js similarity index 100% rename from tools/spectral/ipa/__tests__/eachEnumValueMustBeUpperSnakeCase.test.js rename to tools/spectral/ipa/__tests__/IPA123EachEnumValueMustBeUpperSnakeCase.test.js diff --git a/tools/spectral/ipa/rulesets/IPA-102.yaml b/tools/spectral/ipa/rulesets/IPA-102.yaml index a02018e8d1..358cd73801 100644 --- a/tools/spectral/ipa/rulesets/IPA-102.yaml +++ b/tools/spectral/ipa/rulesets/IPA-102.yaml @@ -30,10 +30,10 @@ rules: xgen-IPA-102-path-alternate-resource-name-path-param: description: | Paths should alternate between resource names and path params. - + ##### Implementation details Rule checks for the following conditions: - + - Paths must follow a pattern where resource names and path parameters strictly alternate - Even-indexed path segments should be resource names (not path parameters) - Odd-indexed path segments should be path parameters @@ -48,10 +48,10 @@ rules: xgen-IPA-102-collection-identifier-pattern: description: | Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. - + ##### Implementation details Rule checks for the following conditions: - + - All path segments that are not path parameters must match pattern `/^[a-z][a-zA-Z0-9]*$/` - Path parameters (inside curly braces) are excluded from validation - Custom methods (segments containing colons) are excluded from validation diff --git a/tools/spectral/ipa/rulesets/IPA-104.yaml b/tools/spectral/ipa/rulesets/IPA-104.yaml index 1a24ec9001..3f764c1663 100644 --- a/tools/spectral/ipa/rulesets/IPA-104.yaml +++ b/tools/spectral/ipa/rulesets/IPA-104.yaml @@ -2,12 +2,12 @@ # http://go/ipa/104 functions: - - eachResourceHasGetMethod - - getMethodReturnsSingleResource - - getMethodReturnsResponseSuffixedObject - - getResponseCodeShouldBe200OK - - getMethodResponseHasNoInputFields - - getMethodHasNoRequestBody + - IPA104EachResourceHasGetMethod + - IPA104GetMethodReturnsSingleResource + - IPA104GetMethodReturnsResponseSuffixedObject + - IPA104GetResponseCodeShouldBe200OK + - IPA104GetMethodResponseHasNoInputFields + - IPA104GetMethodHasNoRequestBody rules: xgen-IPA-104-resource-has-GET: @@ -17,7 +17,7 @@ rules: given: '$.paths' then: field: '@key' - function: 'eachResourceHasGetMethod' + function: 'IPA104EachResourceHasGetMethod' xgen-IPA-104-get-method-returns-single-resource: description: 'The purpose of the Get method is to return data from a single resource.' message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-returns-single-resource' @@ -25,14 +25,14 @@ rules: given: '$.paths[*].get.responses[*].content' then: field: '@key' - function: 'getMethodReturnsSingleResource' + function: 'IPA104GetMethodReturnsSingleResource' xgen-IPA-104-get-method-response-code-is-200: description: 'The Get method must return a 200 OK response.' message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-response-code-is-200' severity: warn given: '$.paths[*].get' then: - function: 'getResponseCodeShouldBe200OK' + function: 'IPA104GetResponseCodeShouldBe200OK' xgen-IPA-104-get-method-returns-response-suffixed-object: description: 'The Get method of a resource should return a "Response" suffixed object.' message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-returns-response-suffixed-object' @@ -40,7 +40,7 @@ rules: given: '$.paths[*].get.responses[*].content' then: field: '@key' - function: 'getMethodReturnsResponseSuffixedObject' + function: 'IPA104GetMethodReturnsResponseSuffixedObject' xgen-IPA-104-get-method-response-has-no-input-fields: description: 'The Get method response object must not include writeOnly properties (fields that should be used only on creation or update, ie output fields).' message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-response-has-no-input-fields' @@ -48,11 +48,11 @@ rules: given: '$.paths[*].get.responses[*].content' then: field: '@key' - function: 'getMethodResponseHasNoInputFields' + function: 'IPA104GetMethodResponseHasNoInputFields' xgen-IPA-104-get-method-no-request-body: description: 'The Get method request must not include a body.' message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-no-request-body' severity: warn given: '$.paths[*].get' then: - function: 'getMethodHasNoRequestBody' + function: 'IPA104GetMethodHasNoRequestBody' diff --git a/tools/spectral/ipa/rulesets/IPA-105.yaml b/tools/spectral/ipa/rulesets/IPA-105.yaml index 26fc3d7b1f..db004218a0 100644 --- a/tools/spectral/ipa/rulesets/IPA-105.yaml +++ b/tools/spectral/ipa/rulesets/IPA-105.yaml @@ -2,10 +2,10 @@ # http://go/ipa/105 functions: - - listResponseCodeShouldBe200OK - - listMethodHasNoRequestBody - - eachResourceHasListMethod - - listMethodResponseIsGetMethodResponse + - IPA105ListResponseCodeShouldBe200OK + - IPA105ListMethodHasNoRequestBody + - IPA105EachResourceHasListMethod + - IPA105ListMethodResponseIsGetMethodResponse rules: xgen-IPA-105-list-method-response-code-is-200: @@ -14,14 +14,14 @@ rules: severity: warn given: '$.paths[*].get' then: - function: 'listResponseCodeShouldBe200OK' + function: 'IPA105ListResponseCodeShouldBe200OK' xgen-IPA-105-list-method-no-request-body: description: 'The List method request must not include a body.' message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-list-method-no-request-body' severity: warn given: '$.paths[*].get' then: - function: 'listMethodHasNoRequestBody' + function: 'IPA105ListMethodHasNoRequestBody' xgen-IPA-105-resource-has-list: description: 'APIs must provide a List method for resources.' message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-105-resource-has-list' @@ -29,7 +29,7 @@ rules: given: '$.paths' then: field: '@key' - function: 'eachResourceHasListMethod' + function: 'IPA105EachResourceHasListMethod' xgen-IPA-105-list-method-response-is-get-method-response: description: >- The response body of the List method should consist of the same resource object returned by the Get method. @@ -49,4 +49,4 @@ rules: given: '$.paths[*].get.responses.200.content' then: field: '@key' - function: 'listMethodResponseIsGetMethodResponse' + function: 'IPA105ListMethodResponseIsGetMethodResponse' diff --git a/tools/spectral/ipa/rulesets/IPA-106.yaml b/tools/spectral/ipa/rulesets/IPA-106.yaml index 1f3239787c..1f674a35cc 100644 --- a/tools/spectral/ipa/rulesets/IPA-106.yaml +++ b/tools/spectral/ipa/rulesets/IPA-106.yaml @@ -2,12 +2,12 @@ # https://mdb.link/mongodb-atlas-openapi-validation# functions: - - createMethodRequestBodyIsRequestSuffixedObject - - createMethodShouldNotHaveQueryParameters - - createMethodRequestBodyIsGetResponse - - createMethodRequestHasNoReadonlyFields - - createMethodResponseCodeIs201Created - - createMethodResponseIsGetMethodResponse + - IPA106CreateMethodRequestBodyIsRequestSuffixedObject + - IPA106CreateMethodShouldNotHaveQueryParameters + - IPA106CreateMethodRequestBodyIsGetResponse + - IPA106CreateMethodRequestHasNoReadonlyFields + - IPA106CreateMethodResponseCodeIs201Created + - IPA106CreateMethodResponseIsGetMethodResponse rules: xgen-IPA-106-create-method-request-body-is-request-suffixed-object: @@ -22,7 +22,7 @@ rules: given: '$.paths[*].post.requestBody.content' then: field: '@key' - function: 'createMethodRequestBodyIsRequestSuffixedObject' + function: 'IPA106CreateMethodRequestBodyIsRequestSuffixedObject' xgen-IPA-106-create-method-should-not-have-query-parameters: description: >- Create operations should not use query parameters. @@ -34,7 +34,7 @@ rules: severity: warn given: '$.paths[*].post' then: - function: 'createMethodShouldNotHaveQueryParameters' + function: 'IPA106CreateMethodShouldNotHaveQueryParameters' functionOptions: ignoredValues: ['pretty', 'envelope'] xgen-IPA-106-create-method-request-body-is-get-method-response: @@ -51,7 +51,7 @@ rules: given: '$.paths[*].post.requestBody.content' then: field: '@key' - function: 'createMethodRequestBodyIsGetResponse' + function: 'IPA106CreateMethodRequestBodyIsGetResponse' xgen-IPA-106-create-method-request-has-no-readonly-fields: description: >- Create method Request object must not include fields with readOnly:true. @@ -64,7 +64,7 @@ rules: given: '$.paths[*].post.requestBody.content' then: field: '@key' - function: 'createMethodRequestHasNoReadonlyFields' + function: 'IPA106CreateMethodRequestHasNoReadonlyFields' xgen-IPA-106-create-method-response-code-is-201: description: >- Create methods must return a 201 Created response code. @@ -76,7 +76,7 @@ rules: severity: warn given: '$.paths[*].post' then: - function: 'createMethodResponseCodeIs201Created' + function: 'IPA106CreateMethodResponseCodeIs201Created' xgen-IPA-106-create-method-response-is-get-method-response: description: >- The response body of the Create method should consist of the same resource object returned by the Get method. @@ -95,4 +95,4 @@ rules: given: '$.paths[*].post.responses.201.content' then: field: '@key' - function: 'createMethodResponseIsGetMethodResponse' + function: 'IPA106CreateMethodResponseIsGetMethodResponse' diff --git a/tools/spectral/ipa/rulesets/IPA-107.yaml b/tools/spectral/ipa/rulesets/IPA-107.yaml index 896ee78f64..92661d29c5 100644 --- a/tools/spectral/ipa/rulesets/IPA-107.yaml +++ b/tools/spectral/ipa/rulesets/IPA-107.yaml @@ -2,8 +2,8 @@ # http://go/ipa/107 functions: - - updateMethodMustNotHaveQueryParams - - updateResponseCodeShouldBe200OK + - IPA107UpdateMethodMustNotHaveQueryParams + - IPA107UpdateResponseCodeShouldBe200OK rules: xgen-IPA-107-put-must-not-have-query-params: @@ -20,7 +20,7 @@ rules: severity: warn given: '$.paths[*].put' then: - function: 'updateMethodMustNotHaveQueryParams' + function: 'IPA107UpdateMethodMustNotHaveQueryParams' functionOptions: ignoredValues: ['pretty', 'envelope'] xgen-IPA-107-patch-must-not-have-query-params: @@ -37,7 +37,7 @@ rules: severity: warn given: '$.paths[*].patch' then: - function: 'updateMethodMustNotHaveQueryParams' + function: 'IPA107UpdateMethodMustNotHaveQueryParams' functionOptions: ignoredValues: ['pretty', 'envelope'] xgen-IPA-107-put-method-response-code-is-200: @@ -53,7 +53,7 @@ rules: severity: warn given: '$.paths[*].put' then: - function: 'updateResponseCodeShouldBe200OK' + function: 'IPA107UpdateResponseCodeShouldBe200OK' xgen-IPA-107-patch-method-response-code-is-200: description: >- The Update method response status code should be 200 OK. @@ -67,4 +67,4 @@ rules: severity: warn given: '$.paths[*].patch' then: - function: 'updateResponseCodeShouldBe200OK' + function: 'IPA107UpdateResponseCodeShouldBe200OK' diff --git a/tools/spectral/ipa/rulesets/IPA-108.yaml b/tools/spectral/ipa/rulesets/IPA-108.yaml index 9a20af4f91..750e85ae29 100644 --- a/tools/spectral/ipa/rulesets/IPA-108.yaml +++ b/tools/spectral/ipa/rulesets/IPA-108.yaml @@ -8,7 +8,7 @@ rules: severity: warn given: $.paths[*].delete.responses[204] then: - function: deleteMethodResponseShouldNotHaveSchema + function: IPA108DeleteMethodResponseShouldNotHaveSchema xgen-IPA-108-delete-method-return-204-response: description: DELETE method must return 204 No Content. @@ -16,7 +16,7 @@ rules: severity: warn given: $.paths[*].delete then: - function: deleteMethod204Response + function: IPA108DeleteMethod204Response xgen-IPA-108-delete-include-404-response: description: DELETE method must include 404 response and return it when resource not found. @@ -24,7 +24,7 @@ rules: severity: warn given: $.paths[*].delete then: - function: deleteMethod404Response + function: IPA108DeleteMethod404Response xgen-IPA-108-delete-request-no-body: description: DELETE method must not have request body. @@ -32,10 +32,10 @@ rules: severity: warn given: $.paths[*].delete then: - function: deleteMethodNoRequestBody + function: IPA108DeleteMethodNoRequestBody functions: - - deleteMethodResponseShouldNotHaveSchema - - deleteMethod204Response - - deleteMethodNoRequestBody - - deleteMethod404Response + - IPA108DeleteMethodResponseShouldNotHaveSchema + - IPA108DeleteMethod204Response + - IPA108DeleteMethodNoRequestBody + - IPA108DeleteMethod404Response diff --git a/tools/spectral/ipa/rulesets/IPA-109.yaml b/tools/spectral/ipa/rulesets/IPA-109.yaml index 0aaafb77cf..f430ed78dc 100644 --- a/tools/spectral/ipa/rulesets/IPA-109.yaml +++ b/tools/spectral/ipa/rulesets/IPA-109.yaml @@ -2,8 +2,8 @@ # http://go/ipa/109 functions: - - eachCustomMethodMustBeGetOrPost - - eachCustomMethodMustUseCamelCase + - IPA109EachCustomMethodMustBeGetOrPost + - IPA109EachCustomMethodMustUseCamelCase rules: xgen-IPA-109-custom-method-must-be-GET-or-POST: @@ -12,7 +12,7 @@ rules: severity: error given: '$.paths[*]' then: - function: 'eachCustomMethodMustBeGetOrPost' + function: 'IPA109EachCustomMethodMustBeGetOrPost' xgen-IPA-109-custom-method-must-use-camel-case: description: 'The custom method must use camelCase format.' @@ -20,4 +20,4 @@ rules: severity: error given: '$.paths[*]' then: - function: 'eachCustomMethodMustUseCamelCase' + function: 'IPA109EachCustomMethodMustUseCamelCase' diff --git a/tools/spectral/ipa/rulesets/IPA-113.yaml b/tools/spectral/ipa/rulesets/IPA-113.yaml index 3078d4d511..18703cece1 100644 --- a/tools/spectral/ipa/rulesets/IPA-113.yaml +++ b/tools/spectral/ipa/rulesets/IPA-113.yaml @@ -2,7 +2,7 @@ # http://go/ipa/113 functions: - - singletonHasNoId + - IPA113SingletonHasNoId rules: xgen-IPA-113-singleton-must-not-have-id: @@ -11,4 +11,4 @@ rules: severity: warn given: '$.paths[*]' then: - function: 'singletonHasNoId' + function: 'IPA113SingletonHasNoId' diff --git a/tools/spectral/ipa/rulesets/IPA-123.yaml b/tools/spectral/ipa/rulesets/IPA-123.yaml index 3464a51cbe..32e7f81522 100644 --- a/tools/spectral/ipa/rulesets/IPA-123.yaml +++ b/tools/spectral/ipa/rulesets/IPA-123.yaml @@ -2,7 +2,7 @@ # http://go/ipa/123 functions: - - eachEnumValueMustBeUpperSnakeCase + - IPA123EachEnumValueMustBeUpperSnakeCase rules: xgen-IPA-123-enum-values-must-be-upper-snake-case: @@ -11,4 +11,4 @@ rules: severity: error given: '$..enum' then: - function: 'eachEnumValueMustBeUpperSnakeCase' + function: 'IPA123EachEnumValueMustBeUpperSnakeCase' diff --git a/tools/spectral/ipa/rulesets/functions/eachResourceHasGetMethod.js b/tools/spectral/ipa/rulesets/functions/IPA104EachResourceHasGetMethod.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/eachResourceHasGetMethod.js rename to tools/spectral/ipa/rulesets/functions/IPA104EachResourceHasGetMethod.js diff --git a/tools/spectral/ipa/rulesets/functions/getMethodHasNoRequestBody.js b/tools/spectral/ipa/rulesets/functions/IPA104GetMethodHasNoRequestBody.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/getMethodHasNoRequestBody.js rename to tools/spectral/ipa/rulesets/functions/IPA104GetMethodHasNoRequestBody.js diff --git a/tools/spectral/ipa/rulesets/functions/getMethodResponseHasNoInputFields.js b/tools/spectral/ipa/rulesets/functions/IPA104GetMethodResponseHasNoInputFields.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/getMethodResponseHasNoInputFields.js rename to tools/spectral/ipa/rulesets/functions/IPA104GetMethodResponseHasNoInputFields.js diff --git a/tools/spectral/ipa/rulesets/functions/getMethodReturnsResponseSuffixedObject.js b/tools/spectral/ipa/rulesets/functions/IPA104GetMethodReturnsResponseSuffixedObject.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/getMethodReturnsResponseSuffixedObject.js rename to tools/spectral/ipa/rulesets/functions/IPA104GetMethodReturnsResponseSuffixedObject.js diff --git a/tools/spectral/ipa/rulesets/functions/getMethodReturnsSingleResource.js b/tools/spectral/ipa/rulesets/functions/IPA104GetMethodReturnsSingleResource.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/getMethodReturnsSingleResource.js rename to tools/spectral/ipa/rulesets/functions/IPA104GetMethodReturnsSingleResource.js diff --git a/tools/spectral/ipa/rulesets/functions/getResponseCodeShouldBe200OK.js b/tools/spectral/ipa/rulesets/functions/IPA104GetResponseCodeShouldBe200OK.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/getResponseCodeShouldBe200OK.js rename to tools/spectral/ipa/rulesets/functions/IPA104GetResponseCodeShouldBe200OK.js diff --git a/tools/spectral/ipa/rulesets/functions/eachResourceHasListMethod.js b/tools/spectral/ipa/rulesets/functions/IPA105EachResourceHasListMethod.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/eachResourceHasListMethod.js rename to tools/spectral/ipa/rulesets/functions/IPA105EachResourceHasListMethod.js diff --git a/tools/spectral/ipa/rulesets/functions/listMethodHasNoRequestBody.js b/tools/spectral/ipa/rulesets/functions/IPA105ListMethodHasNoRequestBody.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/listMethodHasNoRequestBody.js rename to tools/spectral/ipa/rulesets/functions/IPA105ListMethodHasNoRequestBody.js diff --git a/tools/spectral/ipa/rulesets/functions/listMethodResponseIsGetMethodResponse.js b/tools/spectral/ipa/rulesets/functions/IPA105ListMethodResponseIsGetMethodResponse.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/listMethodResponseIsGetMethodResponse.js rename to tools/spectral/ipa/rulesets/functions/IPA105ListMethodResponseIsGetMethodResponse.js diff --git a/tools/spectral/ipa/rulesets/functions/listResponseCodeShouldBe200OK.js b/tools/spectral/ipa/rulesets/functions/IPA105ListResponseCodeShouldBe200OK.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/listResponseCodeShouldBe200OK.js rename to tools/spectral/ipa/rulesets/functions/IPA105ListResponseCodeShouldBe200OK.js diff --git a/tools/spectral/ipa/rulesets/functions/createMethodRequestBodyIsGetResponse.js b/tools/spectral/ipa/rulesets/functions/IPA106CreateMethodRequestBodyIsGetResponse.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/createMethodRequestBodyIsGetResponse.js rename to tools/spectral/ipa/rulesets/functions/IPA106CreateMethodRequestBodyIsGetResponse.js diff --git a/tools/spectral/ipa/rulesets/functions/createMethodRequestBodyIsRequestSuffixedObject.js b/tools/spectral/ipa/rulesets/functions/IPA106CreateMethodRequestBodyIsRequestSuffixedObject.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/createMethodRequestBodyIsRequestSuffixedObject.js rename to tools/spectral/ipa/rulesets/functions/IPA106CreateMethodRequestBodyIsRequestSuffixedObject.js diff --git a/tools/spectral/ipa/rulesets/functions/createMethodRequestHasNoReadonlyFields.js b/tools/spectral/ipa/rulesets/functions/IPA106CreateMethodRequestHasNoReadonlyFields.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/createMethodRequestHasNoReadonlyFields.js rename to tools/spectral/ipa/rulesets/functions/IPA106CreateMethodRequestHasNoReadonlyFields.js diff --git a/tools/spectral/ipa/rulesets/functions/createMethodResponseCodeIs201Created.js b/tools/spectral/ipa/rulesets/functions/IPA106CreateMethodResponseCodeIs201Created.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/createMethodResponseCodeIs201Created.js rename to tools/spectral/ipa/rulesets/functions/IPA106CreateMethodResponseCodeIs201Created.js diff --git a/tools/spectral/ipa/rulesets/functions/createMethodResponseIsGetMethodResponse.js b/tools/spectral/ipa/rulesets/functions/IPA106CreateMethodResponseIsGetMethodResponse.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/createMethodResponseIsGetMethodResponse.js rename to tools/spectral/ipa/rulesets/functions/IPA106CreateMethodResponseIsGetMethodResponse.js diff --git a/tools/spectral/ipa/rulesets/functions/createMethodShouldNotHaveQueryParameters.js b/tools/spectral/ipa/rulesets/functions/IPA106CreateMethodShouldNotHaveQueryParameters.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/createMethodShouldNotHaveQueryParameters.js rename to tools/spectral/ipa/rulesets/functions/IPA106CreateMethodShouldNotHaveQueryParameters.js diff --git a/tools/spectral/ipa/rulesets/functions/updateMethodMustNotHaveQueryParams.js b/tools/spectral/ipa/rulesets/functions/IPA107UpdateMethodMustNotHaveQueryParams.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/updateMethodMustNotHaveQueryParams.js rename to tools/spectral/ipa/rulesets/functions/IPA107UpdateMethodMustNotHaveQueryParams.js diff --git a/tools/spectral/ipa/rulesets/functions/updateResponseCodeShouldBe200OK.js b/tools/spectral/ipa/rulesets/functions/IPA107UpdateResponseCodeShouldBe200OK.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/updateResponseCodeShouldBe200OK.js rename to tools/spectral/ipa/rulesets/functions/IPA107UpdateResponseCodeShouldBe200OK.js diff --git a/tools/spectral/ipa/rulesets/functions/deleteMethod204Response.js b/tools/spectral/ipa/rulesets/functions/IPA108DeleteMethod204Response.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/deleteMethod204Response.js rename to tools/spectral/ipa/rulesets/functions/IPA108DeleteMethod204Response.js diff --git a/tools/spectral/ipa/rulesets/functions/deleteMethod404Response.js b/tools/spectral/ipa/rulesets/functions/IPA108DeleteMethod404Response.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/deleteMethod404Response.js rename to tools/spectral/ipa/rulesets/functions/IPA108DeleteMethod404Response.js diff --git a/tools/spectral/ipa/rulesets/functions/deleteMethodNoRequestBody.js b/tools/spectral/ipa/rulesets/functions/IPA108DeleteMethodNoRequestBody.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/deleteMethodNoRequestBody.js rename to tools/spectral/ipa/rulesets/functions/IPA108DeleteMethodNoRequestBody.js diff --git a/tools/spectral/ipa/rulesets/functions/deleteMethodResponseShouldNotHaveSchema.js b/tools/spectral/ipa/rulesets/functions/IPA108DeleteMethodResponseShouldNotHaveSchema.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/deleteMethodResponseShouldNotHaveSchema.js rename to tools/spectral/ipa/rulesets/functions/IPA108DeleteMethodResponseShouldNotHaveSchema.js diff --git a/tools/spectral/ipa/rulesets/functions/eachCustomMethodMustBeGetOrPost.js b/tools/spectral/ipa/rulesets/functions/IPA109EachCustomMethodMustBeGetOrPost.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/eachCustomMethodMustBeGetOrPost.js rename to tools/spectral/ipa/rulesets/functions/IPA109EachCustomMethodMustBeGetOrPost.js diff --git a/tools/spectral/ipa/rulesets/functions/eachCustomMethodMustUseCamelCase.js b/tools/spectral/ipa/rulesets/functions/IPA109EachCustomMethodMustUseCamelCase.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/eachCustomMethodMustUseCamelCase.js rename to tools/spectral/ipa/rulesets/functions/IPA109EachCustomMethodMustUseCamelCase.js diff --git a/tools/spectral/ipa/rulesets/functions/singletonHasNoId.js b/tools/spectral/ipa/rulesets/functions/IPA113SingletonHasNoId.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/singletonHasNoId.js rename to tools/spectral/ipa/rulesets/functions/IPA113SingletonHasNoId.js diff --git a/tools/spectral/ipa/rulesets/functions/eachEnumValueMustBeUpperSnakeCase.js b/tools/spectral/ipa/rulesets/functions/IPA123EachEnumValueMustBeUpperSnakeCase.js similarity index 100% rename from tools/spectral/ipa/rulesets/functions/eachEnumValueMustBeUpperSnakeCase.js rename to tools/spectral/ipa/rulesets/functions/IPA123EachEnumValueMustBeUpperSnakeCase.js From a3ef3fdf747a30d9daf584e51ee86a91bd71d3dc Mon Sep 17 00:00:00 2001 From: wtrocki Date: Fri, 14 Mar 2025 20:06:17 +0100 Subject: [PATCH 3/4] fix: IPA-104 descriptions --- tools/spectral/ipa/rulesets/IPA-104.yaml | 53 +++++++++++++++++++++--- 1 file changed, 47 insertions(+), 6 deletions(-) diff --git a/tools/spectral/ipa/rulesets/IPA-104.yaml b/tools/spectral/ipa/rulesets/IPA-104.yaml index 3f764c1663..a696d0882c 100644 --- a/tools/spectral/ipa/rulesets/IPA-104.yaml +++ b/tools/spectral/ipa/rulesets/IPA-104.yaml @@ -11,7 +11,14 @@ functions: rules: xgen-IPA-104-resource-has-GET: - description: 'APIs must provide a Get method for resources.' + description: | + APIs must provide a Get method for resources. + + ##### Implementation details + Rule checks for the following conditions: + - Only applies to resource collection identifiers + - For singleton resources, verifies the resource has a GET method + - For regular resources, verifies there is a single resource path with a GET method message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-resource-has-GET' severity: warn given: '$.paths' @@ -19,7 +26,14 @@ rules: field: '@key' function: 'IPA104EachResourceHasGetMethod' xgen-IPA-104-get-method-returns-single-resource: - description: 'The purpose of the Get method is to return data from a single resource.' + description: | + The purpose of the Get method is to return data from a single resource. + + ##### Implementation details + Rule checks for the following conditions: + - Applies only to 2xx responses of GET methods on single resources or singleton resources + - Verifies the response is not an array or paginated result + - Different error messages are provided for standard vs singleton resources message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-returns-single-resource' severity: warn given: '$.paths[*].get.responses[*].content' @@ -27,14 +41,28 @@ rules: field: '@key' function: 'IPA104GetMethodReturnsSingleResource' xgen-IPA-104-get-method-response-code-is-200: - description: 'The Get method must return a 200 OK response.' + description: | + The Get method must return a 200 OK response. + + ##### Implementation details + Rule checks for the following conditions: + - Applies only to GET methods on single resources or singleton resources + - Verifies the 200 OK response code is present + - Fails if the method lacks a 200 OK response or defines a different 2xx status code message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-response-code-is-200' severity: warn given: '$.paths[*].get' then: function: 'IPA104GetResponseCodeShouldBe200OK' xgen-IPA-104-get-method-returns-response-suffixed-object: - description: 'The Get method of a resource should return a "Response" suffixed object.' + description: | + The Get method of a resource should return a "Response" suffixed object. + + ##### Implementation details + Rule checks for the following conditions: + - Applies only to 2xx responses of GET methods on single resources or singleton resources + - Verifies the schema references a predefined schema (not inline) + - Confirms the referenced schema name ends with "Response" suffix message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-returns-response-suffixed-object' severity: warn given: '$.paths[*].get.responses[*].content' @@ -42,7 +70,14 @@ rules: field: '@key' function: 'IPA104GetMethodReturnsResponseSuffixedObject' xgen-IPA-104-get-method-response-has-no-input-fields: - description: 'The Get method response object must not include writeOnly properties (fields that should be used only on creation or update, ie output fields).' + description: | + The Get method response object must not include writeOnly properties (fields that should be used only on creation or update, ie output fields). + + ##### Implementation details + Rule checks for the following conditions: + - Applies only to 2xx responses of GET methods on single resources or singleton resources + - Searches through the schema to find any properties marked with writeOnly attribute + - Fails if any writeOnly properties are found in the response schema message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-response-has-no-input-fields' severity: warn given: '$.paths[*].get.responses[*].content' @@ -50,7 +85,13 @@ rules: field: '@key' function: 'IPA104GetMethodResponseHasNoInputFields' xgen-IPA-104-get-method-no-request-body: - description: 'The Get method request must not include a body.' + description: | + The Get method request must not include a body. + + ##### Implementation details + 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 message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-104-get-method-no-request-body' severity: warn given: '$.paths[*].get' From fd95566da6894e69b88e458d90b5e7d2c8ac80d7 Mon Sep 17 00:00:00 2001 From: wtrocki Date: Fri, 14 Mar 2025 20:47:56 +0100 Subject: [PATCH 4/4] fix: Format --- tools/spectral/ipa/rulesets/IPA-104.yaml | 8 ++--- tools/spectral/ipa/rulesets/README.md | 41 ++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/tools/spectral/ipa/rulesets/IPA-104.yaml b/tools/spectral/ipa/rulesets/IPA-104.yaml index a696d0882c..c50a092d6a 100644 --- a/tools/spectral/ipa/rulesets/IPA-104.yaml +++ b/tools/spectral/ipa/rulesets/IPA-104.yaml @@ -43,7 +43,7 @@ rules: xgen-IPA-104-get-method-response-code-is-200: description: | The Get method must return a 200 OK response. - + ##### Implementation details Rule checks for the following conditions: - Applies only to GET methods on single resources or singleton resources @@ -57,7 +57,7 @@ rules: xgen-IPA-104-get-method-returns-response-suffixed-object: description: | The Get method of a resource should return a "Response" suffixed object. - + ##### Implementation details Rule checks for the following conditions: - Applies only to 2xx responses of GET methods on single resources or singleton resources @@ -72,7 +72,7 @@ rules: xgen-IPA-104-get-method-response-has-no-input-fields: description: | The Get method response object must not include writeOnly properties (fields that should be used only on creation or update, ie output fields). - + ##### Implementation details Rule checks for the following conditions: - Applies only to 2xx responses of GET methods on single resources or singleton resources @@ -87,7 +87,7 @@ rules: xgen-IPA-104-get-method-no-request-body: description: | The Get method request must not include a body. - + ##### Implementation details Rule checks for the following conditions: - Applies only to GET methods on single resources or singleton resources diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index e325a68a4e..f1e80fea76 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -82,27 +82,68 @@ Rule is based on [http://go/ipa/IPA-104](http://go/ipa/IPA-104). ![warn](https://img.shields.io/badge/warning-yellow) APIs must provide a Get method for resources. + +##### Implementation details +Rule checks for the following conditions: + - Only applies to resource collection identifiers + - For singleton resources, verifies the resource has a GET method + - For regular resources, verifies there is a single resource path with a GET method + #### xgen-IPA-104-get-method-returns-single-resource ![warn](https://img.shields.io/badge/warning-yellow) The purpose of the Get method is to return data from a single resource. + +##### Implementation details +Rule checks for the following conditions: + - Applies only to 2xx responses of GET methods on single resources or singleton resources + - Verifies the response is not an array or paginated result + - Different error messages are provided for standard vs singleton resources + #### xgen-IPA-104-get-method-response-code-is-200 ![warn](https://img.shields.io/badge/warning-yellow) The Get method must return a 200 OK response. + +##### Implementation details +Rule checks for the following conditions: + - Applies only to GET methods on single resources or singleton resources + - Verifies the 200 OK response code is present + - Fails if the method lacks a 200 OK response or defines a different 2xx status code + #### xgen-IPA-104-get-method-returns-response-suffixed-object ![warn](https://img.shields.io/badge/warning-yellow) The Get method of a resource should return a "Response" suffixed object. + +##### Implementation details +Rule checks for the following conditions: + - Applies only to 2xx responses of GET methods on single resources or singleton resources + - Verifies the schema references a predefined schema (not inline) + - Confirms the referenced schema name ends with "Response" suffix + #### xgen-IPA-104-get-method-response-has-no-input-fields ![warn](https://img.shields.io/badge/warning-yellow) The Get method response object must not include writeOnly properties (fields that should be used only on creation or update, ie output fields). + +##### Implementation details +Rule checks for the following conditions: + - Applies only to 2xx responses of GET methods on single resources or singleton resources + - Searches through the schema to find any properties marked with writeOnly attribute + - Fails if any writeOnly properties are found in the response schema + #### xgen-IPA-104-get-method-no-request-body ![warn](https://img.shields.io/badge/warning-yellow) The Get method request must not include a body. +##### Implementation details +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 + + ### IPA-105