diff --git a/tools/spectral/ipa/rulesets/IPA-112.yaml b/tools/spectral/ipa/rulesets/IPA-112.yaml index d2a5f0ea21..9f8d7ba540 100644 --- a/tools/spectral/ipa/rulesets/IPA-112.yaml +++ b/tools/spectral/ipa/rulesets/IPA-112.yaml @@ -7,34 +7,34 @@ functions: - IPA112BooleanFieldNamesAvoidIsPrefix rules: - xgen-IPA-112-avoid-project-field-names: - description: | - Schema field names should avoid using "project", "projects", or "projectId". - - ##### Implementation details - Rule checks for the following conditions: - - Searches through all schemas in the API definition - - Identifies property names that match "project" (case-insensitive) - - Ignores fields where prohibited words appear with specified words (e.g., "gcpProjectId") - - Reports any instances where these field names are used - - Suggests using "group", "groups", or "groupId" as alternatives - message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-112-avoid-project-field-names' - severity: warn - given: - - '$.components.schemas..properties' - - '$.paths..requestBody.content[?(@property.match(/json$/i))].schema..properties' - - '$.paths..responses..content[?(@property.match(/json$/i))].schema..properties' - then: - field: '@key' - function: 'IPA112AvoidProjectFieldNames' - functionOptions: - prohibitedFieldNames: - - name: 'project' - alternative: ['group'] - - name: 'projects' - alternative: ['groups'] - ignore: - - 'gcp' +# xgen-IPA-112-avoid-project-field-names: +# description: | +# Schema field names should avoid using "project", "projects", or "projectId". +# +# ##### Implementation details +# Rule checks for the following conditions: +# - Searches through all schemas in the API definition +# - Identifies property names that match "project" (case-insensitive) +# - Ignores fields where prohibited words appear with specified words (e.g., "gcpProjectId") +# - Reports any instances where these field names are used +# - Suggests using "group", "groups", or "groupId" as alternatives +# message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-112-avoid-project-field-names' +# severity: warn +# given: +# - '$.components.schemas..properties' +# - '$.paths..requestBody.content[?(@property.match(/json$/i))].schema..properties' +# - '$.paths..responses..content[?(@property.match(/json$/i))].schema..properties' +# then: +# field: '@key' +# function: 'IPA112AvoidProjectFieldNames' +# functionOptions: +# prohibitedFieldNames: +# - name: 'project' +# alternative: ['group'] +# - name: 'projects' +# alternative: ['groups'] +# ignore: +# - 'gcp' xgen-IPA-112-field-names-are-camel-case: description: | Schema field names should be in camelCase format. @@ -46,6 +46,7 @@ rules: - Reports any instances where these field names are not in camelCase format message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-112-field-names-are-camel-case' severity: warn + resolved: false given: - '$.components.schemas..properties' - '$.paths..requestBody.content[?(@property.match(/json$/i))].schema..properties' @@ -53,21 +54,21 @@ rules: then: field: '@key' function: 'IPA112FieldNamesAreCamelCase' - xgen-IPA-112-boolean-field-names-avoid-is-prefix: - description: | - Boolean field names should avoid the "is" prefix. - - ##### Implementation details - Rule checks for the following conditions: - - Applies only to properties with type 'boolean' - - Identifies property names that start with "is" followed by an uppercase letter - - Suggests using the direct adjective form instead (e.g., "disabled" instead of "isDisabled") - message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-112-boolean-field-names-avoid-is-prefix' - severity: warn - given: - - '$.components.schemas..properties' - - '$.paths..requestBody.content[?(@property.match(/json$/i))].schema..properties' - - '$.paths..responses..content[?(@property.match(/json$/i))].schema..properties' - then: - field: '@key' - function: 'IPA112BooleanFieldNamesAvoidIsPrefix' +# xgen-IPA-112-boolean-field-names-avoid-is-prefix: +# description: | +# Boolean field names should avoid the "is" prefix. +# +# ##### Implementation details +# Rule checks for the following conditions: +# - Applies only to properties with type 'boolean' +# - Identifies property names that start with "is" followed by an uppercase letter +# - Suggests using the direct adjective form instead (e.g., "disabled" instead of "isDisabled") +# message: '{{error}} https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-112-boolean-field-names-avoid-is-prefix' +# severity: warn +# given: +# - '$.components.schemas..properties' +# - '$.paths..requestBody.content[?(@property.match(/json$/i))].schema..properties' +# - '$.paths..responses..content[?(@property.match(/json$/i))].schema..properties' +# then: +# field: '@key' +# function: 'IPA112BooleanFieldNamesAvoidIsPrefix' diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index da9199092e..b154cf4c3d 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -451,19 +451,6 @@ Rule checks for the following conditions: Rules are based on [http://go/ipa/IPA-112](http://go/ipa/IPA-112). -#### xgen-IPA-112-avoid-project-field-names - - ![warn](https://img.shields.io/badge/warning-yellow) -Schema field names should avoid using "project", "projects", or "projectId". - -##### Implementation details -Rule checks for the following conditions: - - Searches through all schemas in the API definition - - Identifies property names that match "project" (case-insensitive) - - Ignores fields where prohibited words appear with specified words (e.g., "gcpProjectId") - - Reports any instances where these field names are used - - Suggests using "group", "groups", or "groupId" as alternatives - #### xgen-IPA-112-field-names-are-camel-case ![warn](https://img.shields.io/badge/warning-yellow) @@ -475,17 +462,6 @@ Rule checks for the following conditions: - Identifies property names that are not in camelCase format - Reports any instances where these field names are not in camelCase format -#### xgen-IPA-112-boolean-field-names-avoid-is-prefix - - ![warn](https://img.shields.io/badge/warning-yellow) -Boolean field names should avoid the "is" prefix. - -##### Implementation details -Rule checks for the following conditions: - - Applies only to properties with type 'boolean' - - Identifies property names that start with "is" followed by an uppercase letter - - Suggests using the direct adjective form instead (e.g., "disabled" instead of "isDisabled") - ### IPA-113 diff --git a/tools/spectral/ipa/rulesets/functions/IPA112FieldNamesAreCamelCase.js b/tools/spectral/ipa/rulesets/functions/IPA112FieldNamesAreCamelCase.js index 4ba51a4054..3d2eb5d84c 100644 --- a/tools/spectral/ipa/rulesets/functions/IPA112FieldNamesAreCamelCase.js +++ b/tools/spectral/ipa/rulesets/functions/IPA112FieldNamesAreCamelCase.js @@ -10,16 +10,10 @@ import { resolveObject } from './utils/componentUtils.js'; const RULE_NAME = 'xgen-IPA-112-field-names-are-camel-case'; -export default (input, options, { path, documentInventory }) => { +export default (input, _, { path, documentInventory }) => { const oas = documentInventory.unresolved; const property = resolveObject(oas, path); - // Skip schema references ($ref): - // Referenced schemas are validated separately to prevent duplicate violations - if (!property) { - return; - } - if (hasException(property, RULE_NAME)) { collectException(property, RULE_NAME, path); return;