From a526f6d894123a2be86a038982bd07dfc9901181 Mon Sep 17 00:00:00 2001 From: wtrocki Date: Thu, 13 Mar 2025 12:20:26 +0100 Subject: [PATCH 1/7] CLOUDP-305862: change format from table to section in markdown --- tools/spectral/ipa/rulesets/IPA-102.yaml | 26 +-- tools/spectral/ipa/rulesets/README.md | 163 ++++++++++++------ .../ipa/scripts/generateRulesetReadme.js | 49 +++--- 3 files changed, 148 insertions(+), 90 deletions(-) diff --git a/tools/spectral/ipa/rulesets/IPA-102.yaml b/tools/spectral/ipa/rulesets/IPA-102.yaml index 756f3412e3..69c7a1a468 100644 --- a/tools/spectral/ipa/rulesets/IPA-102.yaml +++ b/tools/spectral/ipa/rulesets/IPA-102.yaml @@ -3,17 +3,21 @@ rules: xgen-IPA-102-collection-identifier-camelCase: - description: >- - Collection identifiers must be in camelCase. Logic includes:
- - All path segments that are not path parameters
- - Only the resource identifier part before any colon in custom method paths (e.g., `resource` in `/resource:customMethod`)
- - Path parameters should also follow camelCase naming
- - Certain values can be exempted via the ignoredValues configuration (e.g., 'v1', 'v2') that can be supplied as `ignoredValues` - argument to the rule
- - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation
- - Double slashes (//) are not allowed in paths
- http://go/ipa/102 - message: '{{error}} http://go/ipa/102' + description: | + Collection identifiers must be in camelCase. + + ##### Implementation details + Rule checks for the following conditions: + + - All path segments that are not path parameters + - Only the resource identifier part before any colon in custom method paths (e.g., `resource` in `/resource:customMethod`) + - Path parameters should also follow camelCase naming + - Certain values can be exempted via the ignoredValues configuration that can be supplied as `ignoredValues` + argument to the rule + - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation + - Double slashes (//) are not allowed in paths + + message: '{{error}} https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/README.md#ipa-102' severity: warn given: $.paths then: diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 68dc2e78c1..e74587c85e 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -6,95 +6,150 @@ All Spectral rules used in the IPA validation are defined in rulesets grouped by ## Rulesets -The tables below lists all available rules, their descriptions and severity level. +Below is a list of all available rules, their descriptions and severity levels. ### IPA-005 -For rule definitions, see [IPA-005.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/IPA-005.yaml). +Rule is based on [http://go/ipa/IPA-005.yaml](http://go/ipa/IPA-005.yaml). + +#### [error]xgen-IPA-005-exception-extension-format +IPA exception extensions must follow the correct format. http://go/ipa/5 + -| Rule Name | Description | Severity | -| --------------------------------------- | ------------------------------------------------------------------------ | -------- | -| xgen-IPA-005-exception-extension-format | IPA exception extensions must follow the correct format. http://go/ipa/5 | error | ### IPA-102 -For rule definitions, see [IPA-102.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/IPA-102.yaml). +Rule is based on [http://go/ipa/IPA-102.yaml](http://go/ipa/IPA-102.yaml). + +#### [error]xgen-IPA-102-path-alternate-resource-name-path-param +Paths should alternate between resource names and path params. http://go/ipa/102 + +#### [warn]xgen-IPA-102-collection-identifier-camelCase +Collection identifiers must be in camelCase. + + ##### Implementation details + Rule checks for the following conditions: + + - All path segments that are not path parameters + - Only the resource identifier part before any colon in custom method paths (e.g., `resource` in `/resource:customMethod`) + - Path parameters should also follow camelCase naming + - Certain values can be exempted via the ignoredValues configuration that can be supplied as `ignoredValues` + argument to the rule + - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation + - Double slashes (//) are not allowed in paths + + +#### [warn]xgen-IPA-102-collection-identifier-pattern +Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. http://go/ipa/102 + -| Rule Name | Description | Severity | -| ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| xgen-IPA-102-path-alternate-resource-name-path-param | Paths should alternate between resource names and path params. http://go/ipa/102 | error | -| xgen-IPA-102-collection-identifier-camelCase | Collection identifiers must be in camelCase. Logic includes:
- All path segments that are not path parameters
- Only the resource identifier part before any colon in custom method paths (e.g., `resource` in `/resource:customMethod`)
- Path parameters should also follow camelCase naming
- Certain values can be exempted via the ignoredValues configuration (e.g., 'v1', 'v2') that can be supplied as `ignoredValues` argument to the rule
- Paths with `x-xgen-IPA-exception` for this rule are excluded from validation
- Double slashes (//) are not allowed in paths
http://go/ipa/102 | warn | -| xgen-IPA-102-collection-identifier-pattern | Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. http://go/ipa/102 | warn | ### IPA-104 -For rule definitions, see [IPA-104.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/IPA-104.yaml). +Rule is based on [http://go/ipa/IPA-104.yaml](http://go/ipa/IPA-104.yaml). + +#### [warn]xgen-IPA-104-resource-has-GET +APIs must provide a Get method for resources. http://go/ipa/104 + +#### [warn]xgen-IPA-104-get-method-returns-single-resource +The purpose of the Get method is to return data from a single resource. http://go/ipa/104 + +#### [warn]xgen-IPA-104-get-method-response-code-is-200 +The Get method must return a 200 OK response. http://go/ipa/104 + +#### [warn]xgen-IPA-104-get-method-returns-response-suffixed-object +The Get method of a resource should return a "Response" suffixed object. http://go/ipa/104 + +#### [warn]xgen-IPA-104-get-method-response-has-no-input-fields +The Get method response object must not include writeOnly properties (fields that should be used only on creation or update, ie output fields). http://go/ipa/104 + +#### [warn]xgen-IPA-104-get-method-no-request-body +The Get method request must not include a body. http://go/ipa/104 + -| Rule Name | Description | Severity | -| -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -| xgen-IPA-104-resource-has-GET | APIs must provide a Get method for resources. http://go/ipa/104 | warn | -| xgen-IPA-104-get-method-returns-single-resource | The purpose of the Get method is to return data from a single resource. http://go/ipa/104 | warn | -| xgen-IPA-104-get-method-response-code-is-200 | The Get method must return a 200 OK response. http://go/ipa/104 | warn | -| xgen-IPA-104-get-method-returns-response-suffixed-object | The Get method of a resource should return a "Response" suffixed object. http://go/ipa/104 | warn | -| xgen-IPA-104-get-method-response-has-no-input-fields | The Get method response object must not include writeOnly properties (fields that should be used only on creation or update, ie output fields). http://go/ipa/104 | warn | -| xgen-IPA-104-get-method-no-request-body | The Get method request must not include a body. http://go/ipa/104 | warn | ### IPA-105 -For rule definitions, see [IPA-105.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/IPA-105.yaml). +Rule is based on [http://go/ipa/IPA-105.yaml](http://go/ipa/IPA-105.yaml). + +#### [warn]xgen-IPA-105-list-method-response-code-is-200 +The List method must return a 200 OK response. http://go/ipa/105 + +#### [warn]xgen-IPA-105-list-method-no-request-body +The List method request must not include a body. http://go/ipa/105 + +#### [warn]xgen-IPA-105-resource-has-list +APIs must provide a List method for resources. http://go/ipa/105 + -| Rule Name | Description | Severity | -| --------------------------------------------- | ------------------------------------------------------------------ | -------- | -| xgen-IPA-105-list-method-response-code-is-200 | The List method must return a 200 OK response. http://go/ipa/105 | warn | -| xgen-IPA-105-list-method-no-request-body | The List method request must not include a body. http://go/ipa/105 | warn | -| xgen-IPA-105-resource-has-list | APIs must provide a List method for resources. http://go/ipa/105 | warn | ### IPA-106 -For rule definitions, see [IPA-106.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/IPA-106.yaml). +Rule is based on [http://go/ipa/IPA-106.yaml](http://go/ipa/IPA-106.yaml). + +#### [warn]xgen-IPA-106-create-method-request-body-is-request-suffixed-object +The Create method request should be a Request suffixed object. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + +#### [warn]xgen-IPA-106-create-method-should-not-have-query-parameters +Create operations should not use query parameters. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + +#### [warn]xgen-IPA-106-create-method-request-body-is-get-method-response +Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106 readOnly/writeOnly properties will be ignored. This rule applies only to POST requests targeting resource collection URIs. + +#### [warn]xgen-IPA-106-create-method-request-has-no-readonly-fields +Create method Request object must not include fields with readOnly:true. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + +#### [warn]xgen-IPA-106-create-method-response-code-is-201 +Create methods must return a 201 Created response code. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + -| Rule Name | Description | Severity | -| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- | -| xgen-IPA-106-create-method-request-body-is-request-suffixed-object | The Create method request should be a Request suffixed object. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. | warn | -| xgen-IPA-106-create-method-should-not-have-query-parameters | Create operations should not use query parameters. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. | warn | -| xgen-IPA-106-create-method-request-body-is-get-method-response | Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106 readOnly/writeOnly properties will be ignored. This rule applies only to POST requests targeting resource collection URIs. | warn | -| xgen-IPA-106-create-method-request-has-no-readonly-fields | Create method Request object must not include fields with readOnly:true. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. | warn | -| xgen-IPA-106-create-method-response-code-is-201 | Create methods must return a 201 Created response code. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. | warn | ### IPA-108 -For rule definitions, see [IPA-108.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/IPA-108.yaml). +Rule is based on [http://go/ipa/IPA-108.yaml](http://go/ipa/IPA-108.yaml). + +#### [warn]xgen-IPA-108-delete-response-should-be-empty +Delete method response should not have schema reference to object. http://go/ipa/108 + +#### [warn]xgen-IPA-108-delete-method-return-204-response +DELETE method must return 204 No Content. http://go/ipa/108 + +#### [warn]xgen-IPA-108-delete-include-404-response +DELETE method must include 404 response and return it when resource not found. http://go/ipa/108 + +#### [warn]xgen-IPA-108-delete-request-no-body +DELETE method must not have request body. http://go/ipa/108 + -| Rule Name | Description | Severity | -| ---------------------------------------------- | ------------------------------------------------------------------------------------------------ | -------- | -| xgen-IPA-108-delete-response-should-be-empty | Delete method response should not have schema reference to object. http://go/ipa/108 | warn | -| xgen-IPA-108-delete-method-return-204-response | DELETE method must return 204 No Content. http://go/ipa/108 | warn | -| xgen-IPA-108-delete-include-404-response | DELETE method must include 404 response and return it when resource not found. http://go/ipa/108 | warn | -| xgen-IPA-108-delete-request-no-body | DELETE method must not have request body. http://go/ipa/108 | warn | ### IPA-109 -For rule definitions, see [IPA-109.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/IPA-109.yaml). +Rule is based on [http://go/ipa/IPA-109.yaml](http://go/ipa/IPA-109.yaml). + +#### [error]xgen-IPA-109-custom-method-must-be-GET-or-POST +The HTTP method for custom methods must be GET or POST. http://go/ipa/109 + +#### [error]xgen-IPA-109-custom-method-must-use-camel-case +The custom method must use camelCase format. http://go/ipa/109 + -| Rule Name | Description | Severity | -| ---------------------------------------------- | ------------------------------------------------------------------------- | -------- | -| xgen-IPA-109-custom-method-must-be-GET-or-POST | The HTTP method for custom methods must be GET or POST. http://go/ipa/109 | error | -| xgen-IPA-109-custom-method-must-use-camel-case | The custom method must use camelCase format. http://go/ipa/109 | error | ### IPA-113 -For rule definitions, see [IPA-113.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/IPA-113.yaml). +Rule is based on [http://go/ipa/IPA-113.yaml](http://go/ipa/IPA-113.yaml). + +#### [warn]xgen-IPA-113-singleton-must-not-have-id +Singleton resources must not have a user-provided or system-generated ID. http://go/ipa/113 + -| Rule Name | Description | Severity | -| --------------------------------------- | ------------------------------------------------------------------------------------------- | -------- | -| xgen-IPA-113-singleton-must-not-have-id | Singleton resources must not have a user-provided or system-generated ID. http://go/ipa/113 | warn | ### IPA-123 -For rule definitions, see [IPA-123.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/IPA-123.yaml). +Rule is based on [http://go/ipa/IPA-123.yaml](http://go/ipa/IPA-123.yaml). + +#### [error]xgen-IPA-123-enum-values-must-be-upper-snake-case +Enum values must be UPPER_SNAKE_CASE. http://go/ipa/123 + -| Rule Name | Description | Severity | -| ------------------------------------------------- | ------------------------------------------------------- | -------- | -| xgen-IPA-123-enum-values-must-be-upper-snake-case | Enum values must be UPPER_SNAKE_CASE. http://go/ipa/123 | error | diff --git a/tools/spectral/ipa/scripts/generateRulesetReadme.js b/tools/spectral/ipa/scripts/generateRulesetReadme.js index 5e39fa18b6..637dcbe2ec 100644 --- a/tools/spectral/ipa/scripts/generateRulesetReadme.js +++ b/tools/spectral/ipa/scripts/generateRulesetReadme.js @@ -2,7 +2,6 @@ import fs from 'node:fs'; import path from 'path'; import { fileURLToPath } from 'url'; import spectral from '@stoplight/spectral-core'; -import { markdownTable } from 'markdown-table'; import { loadRuleset } from '../utils.js'; const dirname = path.dirname(fileURLToPath(import.meta.url)); @@ -26,7 +25,7 @@ fs.writeFile(readmeFilePath, fileContent, (error) => { async function getRulesetsSection() { let content = - '## Rulesets\n\n' + 'The tables below lists all available rules, their descriptions and severity level.\n\n'; + '## Rulesets\n\n' + 'Below is a list of all available rules, their descriptions and severity levels.\n\n'; const rules = await getAllRules(); const ruleNames = Object.keys(rules); @@ -34,27 +33,36 @@ async function getRulesetsSection() { ipaNumbers.forEach((ipaNumber) => { const ipaRules = filterRulesByIpaNumber(ipaNumber, rules); - const table = generateRulesetTable(ipaRules); - content += - `### ${ipaNumber}\n\n` + `For rule definitions, see ${getIpaRulesetUrl(ipaNumber)}.\n\n` + `${table}\n\n`; + const sections = generateRulesetSections(ipaRules); + content += `### ${ipaNumber}\n\n` + `Rule is based on ${getIpaRulesetUrl(ipaNumber)}.\n\n` + `${sections}\n\n`; }); return content; } -function generateRulesetTable(rules) { - const table = [['Rule Name', 'Description', 'Severity']]; - const tableRows = []; - +function generateRulesetSections(rules) { + let sections = ''; const ruleNames = Object.keys(rules); - ruleNames.forEach((ruleName) => { - const rule = rules[ruleName]; - tableRows.push([ruleName, rule.description, rule.definition.severity]); + const sortedRuleEntries = ruleNames + .map((ruleName) => ({ + name: ruleName, + description: rules[ruleName].description, + severity: rules[ruleName].definition.severity, + })) + .sort((a, b) => { + if (a.severity < b.severity) { + return -1; + } else if (a.severity > b.severity) { + return 1; + } + return 0; + }); + + sortedRuleEntries.forEach((rule) => { + sections += `#### [${rule.severity}]${rule.name} \n${rule.description}\n\n`; }); - tableRows.sort(sortBySeverity); - tableRows.forEach((row) => table.push(row)); - return markdownTable(table); + return sections; } async function getAllRules() { @@ -76,7 +84,7 @@ function getIpaNumbers(ruleNames) { } function getIpaRulesetUrl(ipaNumber) { - return `[${ipaNumber}.yaml](https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/${ipaNumber}.yaml)`; + return `[http://go/ipa/${ipaNumber}.yaml](http://go/ipa/${ipaNumber}.yaml)`; } function filterRulesByIpaNumber(ipaNumber, rules) { @@ -89,12 +97,3 @@ function filterRulesByIpaNumber(ipaNumber, rules) { }; }, {}); } - -function sortBySeverity(a, b) { - if (a[2] < b[2]) { - return -1; - } else if (a[2] > b[2]) { - return 1; - } - return 0; -} From 351efb942126834a8f95b2f2f1154ca8706063ea Mon Sep 17 00:00:00 2001 From: wtrocki Date: Thu, 13 Mar 2025 13:08:23 +0100 Subject: [PATCH 2/7] use url shortener --- .../collectionIdentifierCamelCase.test.js | 30 +++++++++---------- tools/spectral/ipa/rulesets/IPA-102.yaml | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/spectral/ipa/__tests__/collectionIdentifierCamelCase.test.js b/tools/spectral/ipa/__tests__/collectionIdentifierCamelCase.test.js index 9f67d12763..888bf55f75 100644 --- a/tools/spectral/ipa/__tests__/collectionIdentifierCamelCase.test.js +++ b/tools/spectral/ipa/__tests__/collectionIdentifierCamelCase.test.js @@ -45,7 +45,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/Resources'], severity: DiagnosticSeverity.Warning, }, @@ -62,7 +62,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'resource_groups' in path '/resource_groups' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'resource_groups' in path '/resource_groups' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/resource_groups'], severity: DiagnosticSeverity.Warning, }, @@ -79,7 +79,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'resource-groups' in path '/resource-groups' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'resource-groups' in path '/resource-groups' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/resource-groups'], severity: DiagnosticSeverity.Warning, }, @@ -96,7 +96,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources:createResource' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources:createResource' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/Resources:createResource'], severity: DiagnosticSeverity.Warning, }, @@ -113,7 +113,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'resourcesAPI' in path '/resourcesAPI' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'resourcesAPI' in path '/resourcesAPI' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/resourcesAPI'], severity: DiagnosticSeverity.Warning, }, @@ -145,21 +145,21 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path '/api//users' contains double slashes (//) which is not allowed. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path '/api//users' contains double slashes (//) which is not allowed. http://go/ipa-spectral", path: ['paths', '/api//users'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path '/resources///{resourceId}' contains double slashes (//) which is not allowed. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path '/resources///{resourceId}' contains double slashes (//) which is not allowed. http://go/ipa-spectral", path: ['paths', '/resources///{resourceId}'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path '//doubleSlashAtStart' contains double slashes (//) which is not allowed. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path '//doubleSlashAtStart' contains double slashes (//) which is not allowed. http://go/ipa-spectral", path: ['paths', '//doubleSlashAtStart'], severity: DiagnosticSeverity.Warning, }, @@ -186,21 +186,21 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'API' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'API' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/API/Resource_groups/{userId}/User-profiles'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Resource_groups' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'Resource_groups' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/API/Resource_groups/{userId}/User-profiles'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'User-profiles' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'User-profiles' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/API/Resource_groups/{userId}/User-profiles'], severity: DiagnosticSeverity.Warning, }, @@ -217,14 +217,14 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Valid' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'Valid' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/api/Valid/Invalid_resource/{id}:validCustomMethod'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Invalid_resource' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'Invalid_resource' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/api/Valid/Invalid_resource/{id}:validCustomMethod'], severity: DiagnosticSeverity.Warning, }, @@ -241,14 +241,14 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path '/api//Invalid_segment//resources' contains double slashes (//) which is not allowed. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path '/api//Invalid_segment//resources' contains double slashes (//) which is not allowed. http://go/ipa-spectral", path: ['paths', '/api//Invalid_segment//resources'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Invalid_segment' in path '/api//Invalid_segment//resources' is not in camelCase. http://go/ipa/102", + "Collection identifiers must be in camelCase. Path segment 'Invalid_segment' in path '/api//Invalid_segment//resources' is not in camelCase. http://go/ipa-spectral", path: ['paths', '/api//Invalid_segment//resources'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/rulesets/IPA-102.yaml b/tools/spectral/ipa/rulesets/IPA-102.yaml index 69c7a1a468..b899dcbbf7 100644 --- a/tools/spectral/ipa/rulesets/IPA-102.yaml +++ b/tools/spectral/ipa/rulesets/IPA-102.yaml @@ -17,7 +17,7 @@ rules: - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation - Double slashes (//) are not allowed in paths - message: '{{error}} https://github.com/mongodb/openapi/blob/main/tools/spectral/ipa/rulesets/README.md#ipa-102' + message: '{{error}} http://go/ipa-spectral' severity: warn given: $.paths then: From 05a96f1048ae1f6f0963b4bf76a88b00130bd807 Mon Sep 17 00:00:00 2001 From: wtrocki Date: Thu, 13 Mar 2025 13:28:29 +0100 Subject: [PATCH 3/7] fix: use direct ref --- .../collectionIdentifierCamelCase.test.js | 30 +++++++++---------- tools/spectral/ipa/rulesets/IPA-102.yaml | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/spectral/ipa/__tests__/collectionIdentifierCamelCase.test.js b/tools/spectral/ipa/__tests__/collectionIdentifierCamelCase.test.js index 888bf55f75..5dd568047d 100644 --- a/tools/spectral/ipa/__tests__/collectionIdentifierCamelCase.test.js +++ b/tools/spectral/ipa/__tests__/collectionIdentifierCamelCase.test.js @@ -45,7 +45,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/Resources'], severity: DiagnosticSeverity.Warning, }, @@ -62,7 +62,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'resource_groups' in path '/resource_groups' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'resource_groups' in path '/resource_groups' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/resource_groups'], severity: DiagnosticSeverity.Warning, }, @@ -79,7 +79,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'resource-groups' in path '/resource-groups' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'resource-groups' in path '/resource-groups' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/resource-groups'], severity: DiagnosticSeverity.Warning, }, @@ -96,7 +96,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources:createResource' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'Resources' in path '/Resources:createResource' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/Resources:createResource'], severity: DiagnosticSeverity.Warning, }, @@ -113,7 +113,7 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'resourcesAPI' in path '/resourcesAPI' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'resourcesAPI' in path '/resourcesAPI' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/resourcesAPI'], severity: DiagnosticSeverity.Warning, }, @@ -145,21 +145,21 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path '/api//users' contains double slashes (//) which is not allowed. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path '/api//users' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102", path: ['paths', '/api//users'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path '/resources///{resourceId}' contains double slashes (//) which is not allowed. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path '/resources///{resourceId}' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102", path: ['paths', '/resources///{resourceId}'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path '//doubleSlashAtStart' contains double slashes (//) which is not allowed. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path '//doubleSlashAtStart' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102", path: ['paths', '//doubleSlashAtStart'], severity: DiagnosticSeverity.Warning, }, @@ -186,21 +186,21 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'API' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'API' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/API/Resource_groups/{userId}/User-profiles'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Resource_groups' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'Resource_groups' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/API/Resource_groups/{userId}/User-profiles'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'User-profiles' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'User-profiles' in path '/API/Resource_groups/{userId}/User-profiles' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/API/Resource_groups/{userId}/User-profiles'], severity: DiagnosticSeverity.Warning, }, @@ -217,14 +217,14 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Valid' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'Valid' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/api/Valid/Invalid_resource/{id}:validCustomMethod'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Invalid_resource' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'Invalid_resource' in path '/api/Valid/Invalid_resource/{id}:validCustomMethod' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/api/Valid/Invalid_resource/{id}:validCustomMethod'], severity: DiagnosticSeverity.Warning, }, @@ -241,14 +241,14 @@ testRule('xgen-IPA-102-collection-identifier-camelCase', [ { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path '/api//Invalid_segment//resources' contains double slashes (//) which is not allowed. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path '/api//Invalid_segment//resources' contains double slashes (//) which is not allowed. http://go/ipa-spectral#IPA-102", path: ['paths', '/api//Invalid_segment//resources'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-102-collection-identifier-camelCase', message: - "Collection identifiers must be in camelCase. Path segment 'Invalid_segment' in path '/api//Invalid_segment//resources' is not in camelCase. http://go/ipa-spectral", + "Collection identifiers must be in camelCase. Path segment 'Invalid_segment' in path '/api//Invalid_segment//resources' is not in camelCase. http://go/ipa-spectral#IPA-102", path: ['paths', '/api//Invalid_segment//resources'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/rulesets/IPA-102.yaml b/tools/spectral/ipa/rulesets/IPA-102.yaml index b899dcbbf7..cfc5c5a1b8 100644 --- a/tools/spectral/ipa/rulesets/IPA-102.yaml +++ b/tools/spectral/ipa/rulesets/IPA-102.yaml @@ -17,7 +17,7 @@ rules: - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation - Double slashes (//) are not allowed in paths - message: '{{error}} http://go/ipa-spectral' + message: '{{error}} http://go/ipa-spectral#IPA-102' severity: warn given: $.paths then: From 9657086fddd292e6d584abc4e712911a2f85c193 Mon Sep 17 00:00:00 2001 From: wtrocki Date: Thu, 13 Mar 2025 13:50:42 +0100 Subject: [PATCH 4/7] fix: formatting of severities --- tools/spectral/ipa/rulesets/README.md | 148 ++++++++++-------- .../ipa/scripts/generateRulesetReadme.js | 18 ++- 2 files changed, 103 insertions(+), 63 deletions(-) diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index e74587c85e..fcbd6140e6 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -10,22 +10,25 @@ Below is a list of all available rules, their descriptions and severity levels. ### IPA-005 -Rule is based on [http://go/ipa/IPA-005.yaml](http://go/ipa/IPA-005.yaml). +Rule is based on [http://go/ipa-spectral#IPA-005](http://go/ipa-spectral#IPA-005). -#### [error]xgen-IPA-005-exception-extension-format -IPA exception extensions must follow the correct format. http://go/ipa/5 +#### xgen-IPA-005-exception-extension-format + + ❌ ![](https://img.shields.io/badge/error-red) IPA exception extensions must follow the correct format. http://go/ipa/5 ### IPA-102 -Rule is based on [http://go/ipa/IPA-102.yaml](http://go/ipa/IPA-102.yaml). +Rule is based on [http://go/ipa-spectral#IPA-102](http://go/ipa-spectral#IPA-102). + +#### xgen-IPA-102-path-alternate-resource-name-path-param -#### [error]xgen-IPA-102-path-alternate-resource-name-path-param -Paths should alternate between resource names and path params. http://go/ipa/102 + ❌ ![](https://img.shields.io/badge/error-red) Paths should alternate between resource names and path params. http://go/ipa/102 -#### [warn]xgen-IPA-102-collection-identifier-camelCase -Collection identifiers must be in camelCase. +#### xgen-IPA-102-collection-identifier-camelCase + + ⚠️ ![](https://img.shields.io/badge/warning-yellow) Collection identifiers must be in camelCase. ##### Implementation details Rule checks for the following conditions: @@ -39,116 +42,139 @@ Collection identifiers must be in camelCase. - Double slashes (//) are not allowed in paths -#### [warn]xgen-IPA-102-collection-identifier-pattern -Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. http://go/ipa/102 +#### xgen-IPA-102-collection-identifier-pattern + + ⚠️ ![](https://img.shields.io/badge/warning-yellow) Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. http://go/ipa/102 ### IPA-104 -Rule is based on [http://go/ipa/IPA-104.yaml](http://go/ipa/IPA-104.yaml). +Rule is based on [http://go/ipa-spectral#IPA-104](http://go/ipa-spectral#IPA-104). + +#### xgen-IPA-104-resource-has-GET + + ⚠️ ![](https://img.shields.io/badge/warning-yellow) APIs must provide a Get method for resources. http://go/ipa/104 + +#### xgen-IPA-104-get-method-returns-single-resource -#### [warn]xgen-IPA-104-resource-has-GET -APIs must provide a Get method for resources. http://go/ipa/104 + ⚠️ ![](https://img.shields.io/badge/warning-yellow) The purpose of the Get method is to return data from a single resource. http://go/ipa/104 -#### [warn]xgen-IPA-104-get-method-returns-single-resource -The purpose of the Get method is to return data from a single resource. http://go/ipa/104 +#### xgen-IPA-104-get-method-response-code-is-200 -#### [warn]xgen-IPA-104-get-method-response-code-is-200 -The Get method must return a 200 OK response. http://go/ipa/104 + ⚠️ ![](https://img.shields.io/badge/warning-yellow) The Get method must return a 200 OK response. http://go/ipa/104 -#### [warn]xgen-IPA-104-get-method-returns-response-suffixed-object -The Get method of a resource should return a "Response" suffixed object. http://go/ipa/104 +#### xgen-IPA-104-get-method-returns-response-suffixed-object -#### [warn]xgen-IPA-104-get-method-response-has-no-input-fields -The Get method response object must not include writeOnly properties (fields that should be used only on creation or update, ie output fields). http://go/ipa/104 + ⚠️ ![](https://img.shields.io/badge/warning-yellow) The Get method of a resource should return a "Response" suffixed object. http://go/ipa/104 -#### [warn]xgen-IPA-104-get-method-no-request-body -The Get method request must not include a body. http://go/ipa/104 +#### xgen-IPA-104-get-method-response-has-no-input-fields + + ⚠️ ![](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). http://go/ipa/104 + +#### xgen-IPA-104-get-method-no-request-body + + ⚠️ ![](https://img.shields.io/badge/warning-yellow) The Get method request must not include a body. http://go/ipa/104 ### IPA-105 -Rule is based on [http://go/ipa/IPA-105.yaml](http://go/ipa/IPA-105.yaml). +Rule is based on [http://go/ipa-spectral#IPA-105](http://go/ipa-spectral#IPA-105). + +#### xgen-IPA-105-list-method-response-code-is-200 + + ⚠️ ![](https://img.shields.io/badge/warning-yellow) The List method must return a 200 OK response. http://go/ipa/105 + +#### xgen-IPA-105-list-method-no-request-body -#### [warn]xgen-IPA-105-list-method-response-code-is-200 -The List method must return a 200 OK response. http://go/ipa/105 + ⚠️ ![](https://img.shields.io/badge/warning-yellow) The List method request must not include a body. http://go/ipa/105 -#### [warn]xgen-IPA-105-list-method-no-request-body -The List method request must not include a body. http://go/ipa/105 +#### xgen-IPA-105-resource-has-list -#### [warn]xgen-IPA-105-resource-has-list -APIs must provide a List method for resources. http://go/ipa/105 + ⚠️ ![](https://img.shields.io/badge/warning-yellow) APIs must provide a List method for resources. http://go/ipa/105 ### IPA-106 -Rule is based on [http://go/ipa/IPA-106.yaml](http://go/ipa/IPA-106.yaml). +Rule is based on [http://go/ipa-spectral#IPA-106](http://go/ipa-spectral#IPA-106). -#### [warn]xgen-IPA-106-create-method-request-body-is-request-suffixed-object -The Create method request should be a Request suffixed object. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. +#### xgen-IPA-106-create-method-request-body-is-request-suffixed-object -#### [warn]xgen-IPA-106-create-method-should-not-have-query-parameters -Create operations should not use query parameters. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + ⚠️ ![](https://img.shields.io/badge/warning-yellow) The Create method request should be a Request suffixed object. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. -#### [warn]xgen-IPA-106-create-method-request-body-is-get-method-response -Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106 readOnly/writeOnly properties will be ignored. This rule applies only to POST requests targeting resource collection URIs. +#### xgen-IPA-106-create-method-should-not-have-query-parameters -#### [warn]xgen-IPA-106-create-method-request-has-no-readonly-fields -Create method Request object must not include fields with readOnly:true. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + ⚠️ ![](https://img.shields.io/badge/warning-yellow) Create operations should not use query parameters. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. -#### [warn]xgen-IPA-106-create-method-response-code-is-201 -Create methods must return a 201 Created response code. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. +#### xgen-IPA-106-create-method-request-body-is-get-method-response + + ⚠️ ![](https://img.shields.io/badge/warning-yellow) Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106 readOnly/writeOnly properties will be ignored. This rule applies only to POST requests targeting resource collection URIs. + +#### xgen-IPA-106-create-method-request-has-no-readonly-fields + + ⚠️ ![](https://img.shields.io/badge/warning-yellow) Create method Request object must not include fields with readOnly:true. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + +#### xgen-IPA-106-create-method-response-code-is-201 + + ⚠️ ![](https://img.shields.io/badge/warning-yellow) Create methods must return a 201 Created response code. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. ### IPA-108 -Rule is based on [http://go/ipa/IPA-108.yaml](http://go/ipa/IPA-108.yaml). +Rule is based on [http://go/ipa-spectral#IPA-108](http://go/ipa-spectral#IPA-108). + +#### xgen-IPA-108-delete-response-should-be-empty + + ⚠️ ![](https://img.shields.io/badge/warning-yellow) Delete method response should not have schema reference to object. http://go/ipa/108 -#### [warn]xgen-IPA-108-delete-response-should-be-empty -Delete method response should not have schema reference to object. http://go/ipa/108 +#### xgen-IPA-108-delete-method-return-204-response -#### [warn]xgen-IPA-108-delete-method-return-204-response -DELETE method must return 204 No Content. http://go/ipa/108 + ⚠️ ![](https://img.shields.io/badge/warning-yellow) DELETE method must return 204 No Content. http://go/ipa/108 -#### [warn]xgen-IPA-108-delete-include-404-response -DELETE method must include 404 response and return it when resource not found. http://go/ipa/108 +#### xgen-IPA-108-delete-include-404-response -#### [warn]xgen-IPA-108-delete-request-no-body -DELETE method must not have request body. http://go/ipa/108 + ⚠️ ![](https://img.shields.io/badge/warning-yellow) DELETE method must include 404 response and return it when resource not found. http://go/ipa/108 + +#### xgen-IPA-108-delete-request-no-body + + ⚠️ ![](https://img.shields.io/badge/warning-yellow) DELETE method must not have request body. http://go/ipa/108 ### IPA-109 -Rule is based on [http://go/ipa/IPA-109.yaml](http://go/ipa/IPA-109.yaml). +Rule is based on [http://go/ipa-spectral#IPA-109](http://go/ipa-spectral#IPA-109). + +#### xgen-IPA-109-custom-method-must-be-GET-or-POST -#### [error]xgen-IPA-109-custom-method-must-be-GET-or-POST -The HTTP method for custom methods must be GET or POST. http://go/ipa/109 + ❌ ![](https://img.shields.io/badge/error-red) The HTTP method for custom methods must be GET or POST. http://go/ipa/109 -#### [error]xgen-IPA-109-custom-method-must-use-camel-case -The custom method must use camelCase format. http://go/ipa/109 +#### xgen-IPA-109-custom-method-must-use-camel-case + + ❌ ![](https://img.shields.io/badge/error-red) The custom method must use camelCase format. http://go/ipa/109 ### IPA-113 -Rule is based on [http://go/ipa/IPA-113.yaml](http://go/ipa/IPA-113.yaml). +Rule is based on [http://go/ipa-spectral#IPA-113](http://go/ipa-spectral#IPA-113). + +#### xgen-IPA-113-singleton-must-not-have-id -#### [warn]xgen-IPA-113-singleton-must-not-have-id -Singleton resources must not have a user-provided or system-generated ID. http://go/ipa/113 + ⚠️ ![](https://img.shields.io/badge/warning-yellow) Singleton resources must not have a user-provided or system-generated ID. http://go/ipa/113 ### IPA-123 -Rule is based on [http://go/ipa/IPA-123.yaml](http://go/ipa/IPA-123.yaml). +Rule is based on [http://go/ipa-spectral#IPA-123](http://go/ipa-spectral#IPA-123). + +#### xgen-IPA-123-enum-values-must-be-upper-snake-case -#### [error]xgen-IPA-123-enum-values-must-be-upper-snake-case -Enum values must be UPPER_SNAKE_CASE. http://go/ipa/123 + ❌ ![](https://img.shields.io/badge/error-red) Enum values must be UPPER_SNAKE_CASE. http://go/ipa/123 diff --git a/tools/spectral/ipa/scripts/generateRulesetReadme.js b/tools/spectral/ipa/scripts/generateRulesetReadme.js index 637dcbe2ec..5086fa7256 100644 --- a/tools/spectral/ipa/scripts/generateRulesetReadme.js +++ b/tools/spectral/ipa/scripts/generateRulesetReadme.js @@ -59,12 +59,26 @@ function generateRulesetSections(rules) { }); sortedRuleEntries.forEach((rule) => { - sections += `#### [${rule.severity}]${rule.name} \n${rule.description}\n\n`; + const severityFormatted = formatSeverity(rule.severity); + sections += `#### ${rule.name}\n\n ${severityFormatted} ${rule.description}\n\n`; }); return sections; } +function formatSeverity(severity) { + switch (severity.toLowerCase()) { + case 'info': + return '💡 ![](https://img.shields.io/badge/info-green)'; + case 'warn': + return '⚠️ ![](https://img.shields.io/badge/warning-yellow)'; + case 'error': + return '❌ ![](https://img.shields.io/badge/error-red)'; + default: + return `\`${severity}\``; + } +} + async function getAllRules() { const rulesetFilePath = path.join(dirname, '..', 'ipa-spectral.yaml'); const { Spectral } = spectral; @@ -84,7 +98,7 @@ function getIpaNumbers(ruleNames) { } function getIpaRulesetUrl(ipaNumber) { - return `[http://go/ipa/${ipaNumber}.yaml](http://go/ipa/${ipaNumber}.yaml)`; + return `[http://go/ipa-spectral#${ipaNumber}](http://go/ipa-spectral#${ipaNumber})`; } function filterRulesByIpaNumber(ipaNumber, rules) { From 7000ff5ada6ca22dc643d671b98d6e1a336c8709 Mon Sep 17 00:00:00 2001 From: Wojciech Trocki Date: Thu, 13 Mar 2025 15:03:05 +0100 Subject: [PATCH 5/7] Apply suggestions from code review --- tools/spectral/ipa/rulesets/README.md | 96 ++++++++++++------- .../ipa/scripts/generateRulesetReadme.js | 10 +- 2 files changed, 66 insertions(+), 40 deletions(-) diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index fcbd6140e6..1145cfaf98 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -10,25 +10,28 @@ Below is a list of all available rules, their descriptions and severity levels. ### IPA-005 -Rule is based on [http://go/ipa-spectral#IPA-005](http://go/ipa-spectral#IPA-005). +Rule is based on [http://go/ipa/IPA-005](http://go/ipa/IPA-005). #### xgen-IPA-005-exception-extension-format - ❌ ![](https://img.shields.io/badge/error-red) IPA exception extensions must follow the correct format. http://go/ipa/5 + ![](https://img.shields.io/badge/error-red) +IPA exception extensions must follow the correct format. http://go/ipa/5 ### IPA-102 -Rule is based on [http://go/ipa-spectral#IPA-102](http://go/ipa-spectral#IPA-102). +Rule is based on [http://go/ipa/IPA-102](http://go/ipa/IPA-102). #### xgen-IPA-102-path-alternate-resource-name-path-param - ❌ ![](https://img.shields.io/badge/error-red) Paths should alternate between resource names and path params. http://go/ipa/102 + ![](https://img.shields.io/badge/error-red) +Paths should alternate between resource names and path params. http://go/ipa/102 #### xgen-IPA-102-collection-identifier-camelCase - ⚠️ ![](https://img.shields.io/badge/warning-yellow) Collection identifiers must be in camelCase. + ![](https://img.shields.io/badge/warning-yellow) +Collection identifiers must be in camelCase. ##### Implementation details Rule checks for the following conditions: @@ -44,137 +47,160 @@ Rule is based on [http://go/ipa-spectral#IPA-102](http://go/ipa-spectral#IPA-102 #### xgen-IPA-102-collection-identifier-pattern - ⚠️ ![](https://img.shields.io/badge/warning-yellow) Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. http://go/ipa/102 + ![](https://img.shields.io/badge/warning-yellow) +Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. http://go/ipa/102 ### IPA-104 -Rule is based on [http://go/ipa-spectral#IPA-104](http://go/ipa-spectral#IPA-104). +Rule is based on [http://go/ipa/IPA-104](http://go/ipa/IPA-104). #### xgen-IPA-104-resource-has-GET - ⚠️ ![](https://img.shields.io/badge/warning-yellow) APIs must provide a Get method for resources. http://go/ipa/104 + ![](https://img.shields.io/badge/warning-yellow) +APIs must provide a Get method for resources. http://go/ipa/104 #### xgen-IPA-104-get-method-returns-single-resource - ⚠️ ![](https://img.shields.io/badge/warning-yellow) The purpose of the Get method is to return data from a single resource. http://go/ipa/104 + ![](https://img.shields.io/badge/warning-yellow) +The purpose of the Get method is to return data from a single resource. http://go/ipa/104 #### xgen-IPA-104-get-method-response-code-is-200 - ⚠️ ![](https://img.shields.io/badge/warning-yellow) The Get method must return a 200 OK response. http://go/ipa/104 + ![](https://img.shields.io/badge/warning-yellow) +The Get method must return a 200 OK response. http://go/ipa/104 #### xgen-IPA-104-get-method-returns-response-suffixed-object - ⚠️ ![](https://img.shields.io/badge/warning-yellow) The Get method of a resource should return a "Response" suffixed object. http://go/ipa/104 + ![](https://img.shields.io/badge/warning-yellow) +The Get method of a resource should return a "Response" suffixed object. http://go/ipa/104 #### xgen-IPA-104-get-method-response-has-no-input-fields - ⚠️ ![](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). http://go/ipa/104 + ![](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). http://go/ipa/104 #### xgen-IPA-104-get-method-no-request-body - ⚠️ ![](https://img.shields.io/badge/warning-yellow) The Get method request must not include a body. http://go/ipa/104 + ![](https://img.shields.io/badge/warning-yellow) +The Get method request must not include a body. http://go/ipa/104 ### IPA-105 -Rule is based on [http://go/ipa-spectral#IPA-105](http://go/ipa-spectral#IPA-105). +Rule is based on [http://go/ipa/IPA-105](http://go/ipa/IPA-105). #### xgen-IPA-105-list-method-response-code-is-200 - ⚠️ ![](https://img.shields.io/badge/warning-yellow) The List method must return a 200 OK response. http://go/ipa/105 + ![](https://img.shields.io/badge/warning-yellow) +The List method must return a 200 OK response. http://go/ipa/105 #### xgen-IPA-105-list-method-no-request-body - ⚠️ ![](https://img.shields.io/badge/warning-yellow) The List method request must not include a body. http://go/ipa/105 + ![](https://img.shields.io/badge/warning-yellow) +The List method request must not include a body. http://go/ipa/105 #### xgen-IPA-105-resource-has-list - ⚠️ ![](https://img.shields.io/badge/warning-yellow) APIs must provide a List method for resources. http://go/ipa/105 + ![](https://img.shields.io/badge/warning-yellow) +APIs must provide a List method for resources. http://go/ipa/105 ### IPA-106 -Rule is based on [http://go/ipa-spectral#IPA-106](http://go/ipa-spectral#IPA-106). +Rule is based on [http://go/ipa/IPA-106](http://go/ipa/IPA-106). #### xgen-IPA-106-create-method-request-body-is-request-suffixed-object - ⚠️ ![](https://img.shields.io/badge/warning-yellow) The Create method request should be a Request suffixed object. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + ![](https://img.shields.io/badge/warning-yellow) +The Create method request should be a Request suffixed object. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. #### xgen-IPA-106-create-method-should-not-have-query-parameters - ⚠️ ![](https://img.shields.io/badge/warning-yellow) Create operations should not use query parameters. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + ![](https://img.shields.io/badge/warning-yellow) +Create operations should not use query parameters. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. #### xgen-IPA-106-create-method-request-body-is-get-method-response - ⚠️ ![](https://img.shields.io/badge/warning-yellow) Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106 readOnly/writeOnly properties will be ignored. This rule applies only to POST requests targeting resource collection URIs. + ![](https://img.shields.io/badge/warning-yellow) +Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106 readOnly/writeOnly properties will be ignored. This rule applies only to POST requests targeting resource collection URIs. #### xgen-IPA-106-create-method-request-has-no-readonly-fields - ⚠️ ![](https://img.shields.io/badge/warning-yellow) Create method Request object must not include fields with readOnly:true. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + ![](https://img.shields.io/badge/warning-yellow) +Create method Request object must not include fields with readOnly:true. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. #### xgen-IPA-106-create-method-response-code-is-201 - ⚠️ ![](https://img.shields.io/badge/warning-yellow) Create methods must return a 201 Created response code. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. + ![](https://img.shields.io/badge/warning-yellow) +Create methods must return a 201 Created response code. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. ### IPA-108 -Rule is based on [http://go/ipa-spectral#IPA-108](http://go/ipa-spectral#IPA-108). +Rule is based on [http://go/ipa/IPA-108](http://go/ipa/IPA-108). #### xgen-IPA-108-delete-response-should-be-empty - ⚠️ ![](https://img.shields.io/badge/warning-yellow) Delete method response should not have schema reference to object. http://go/ipa/108 + ![](https://img.shields.io/badge/warning-yellow) +Delete method response should not have schema reference to object. http://go/ipa/108 #### xgen-IPA-108-delete-method-return-204-response - ⚠️ ![](https://img.shields.io/badge/warning-yellow) DELETE method must return 204 No Content. http://go/ipa/108 + ![](https://img.shields.io/badge/warning-yellow) +DELETE method must return 204 No Content. http://go/ipa/108 #### xgen-IPA-108-delete-include-404-response - ⚠️ ![](https://img.shields.io/badge/warning-yellow) DELETE method must include 404 response and return it when resource not found. http://go/ipa/108 + ![](https://img.shields.io/badge/warning-yellow) +DELETE method must include 404 response and return it when resource not found. http://go/ipa/108 #### xgen-IPA-108-delete-request-no-body - ⚠️ ![](https://img.shields.io/badge/warning-yellow) DELETE method must not have request body. http://go/ipa/108 + ![](https://img.shields.io/badge/warning-yellow) +DELETE method must not have request body. http://go/ipa/108 ### IPA-109 -Rule is based on [http://go/ipa-spectral#IPA-109](http://go/ipa-spectral#IPA-109). +Rule is based on [http://go/ipa/IPA-109](http://go/ipa/IPA-109). #### xgen-IPA-109-custom-method-must-be-GET-or-POST - ❌ ![](https://img.shields.io/badge/error-red) The HTTP method for custom methods must be GET or POST. http://go/ipa/109 + ![](https://img.shields.io/badge/error-red) +The HTTP method for custom methods must be GET or POST. http://go/ipa/109 #### xgen-IPA-109-custom-method-must-use-camel-case - ❌ ![](https://img.shields.io/badge/error-red) The custom method must use camelCase format. http://go/ipa/109 + ![](https://img.shields.io/badge/error-red) +The custom method must use camelCase format. http://go/ipa/109 ### IPA-113 -Rule is based on [http://go/ipa-spectral#IPA-113](http://go/ipa-spectral#IPA-113). +Rule is based on [http://go/ipa/IPA-113](http://go/ipa/IPA-113). #### xgen-IPA-113-singleton-must-not-have-id - ⚠️ ![](https://img.shields.io/badge/warning-yellow) Singleton resources must not have a user-provided or system-generated ID. http://go/ipa/113 + ![](https://img.shields.io/badge/warning-yellow) +Singleton resources must not have a user-provided or system-generated ID. http://go/ipa/113 ### IPA-123 -Rule is based on [http://go/ipa-spectral#IPA-123](http://go/ipa-spectral#IPA-123). +Rule is based on [http://go/ipa/IPA-123](http://go/ipa/IPA-123). #### xgen-IPA-123-enum-values-must-be-upper-snake-case - ❌ ![](https://img.shields.io/badge/error-red) Enum values must be UPPER_SNAKE_CASE. http://go/ipa/123 + ![](https://img.shields.io/badge/error-red) +Enum values must be UPPER_SNAKE_CASE. http://go/ipa/123 diff --git a/tools/spectral/ipa/scripts/generateRulesetReadme.js b/tools/spectral/ipa/scripts/generateRulesetReadme.js index 5086fa7256..2d252089fd 100644 --- a/tools/spectral/ipa/scripts/generateRulesetReadme.js +++ b/tools/spectral/ipa/scripts/generateRulesetReadme.js @@ -60,7 +60,7 @@ function generateRulesetSections(rules) { sortedRuleEntries.forEach((rule) => { const severityFormatted = formatSeverity(rule.severity); - sections += `#### ${rule.name}\n\n ${severityFormatted} ${rule.description}\n\n`; + sections += `#### ${rule.name}\n\n ${severityFormatted} \n${rule.description}\n\n`; }); return sections; @@ -69,11 +69,11 @@ function generateRulesetSections(rules) { function formatSeverity(severity) { switch (severity.toLowerCase()) { case 'info': - return '💡 ![](https://img.shields.io/badge/info-green)'; + return '![](https://img.shields.io/badge/info-green)'; case 'warn': - return '⚠️ ![](https://img.shields.io/badge/warning-yellow)'; + return '![](https://img.shields.io/badge/warning-yellow)'; case 'error': - return '❌ ![](https://img.shields.io/badge/error-red)'; + return '![](https://img.shields.io/badge/error-red)'; default: return `\`${severity}\``; } @@ -98,7 +98,7 @@ function getIpaNumbers(ruleNames) { } function getIpaRulesetUrl(ipaNumber) { - return `[http://go/ipa-spectral#${ipaNumber}](http://go/ipa-spectral#${ipaNumber})`; + return `[http://go/ipa/${ipaNumber}](http://go/ipa/${ipaNumber})`; } function filterRulesByIpaNumber(ipaNumber, rules) { From c9e32271abef743241ece6ea9a6ffa33ea060b97 Mon Sep 17 00:00:00 2001 From: wtrocki Date: Thu, 13 Mar 2025 17:11:08 +0100 Subject: [PATCH 6/7] fix: paths format --- tools/spectral/ipa/rulesets/README.md | 2 +- tools/spectral/ipa/scripts/generateRulesetReadme.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 1145cfaf98..2b6c5ca3fb 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -10,7 +10,7 @@ Below is a list of all available rules, their descriptions and severity levels. ### IPA-005 -Rule is based on [http://go/ipa/IPA-005](http://go/ipa/IPA-005). +Rule is based on [http://go/ipa/IPA-5](http://go/ipa/IPA-5). #### xgen-IPA-005-exception-extension-format diff --git a/tools/spectral/ipa/scripts/generateRulesetReadme.js b/tools/spectral/ipa/scripts/generateRulesetReadme.js index 2d252089fd..89c9698c6a 100644 --- a/tools/spectral/ipa/scripts/generateRulesetReadme.js +++ b/tools/spectral/ipa/scripts/generateRulesetReadme.js @@ -98,7 +98,12 @@ function getIpaNumbers(ruleNames) { } function getIpaRulesetUrl(ipaNumber) { - return `[http://go/ipa/${ipaNumber}](http://go/ipa/${ipaNumber})`; + const parts = ipaNumber.split('-'); + if (parts.length > 1) { + parts[1] = parts[1].replace(/^0+/, ''); + } + const ipaNumberFormatted = parts.join('-'); + return `[http://go/ipa/${ipaNumberFormatted}](http://go/ipa/${ipaNumberFormatted})`; } function filterRulesByIpaNumber(ipaNumber, rules) { From c2c3a8c8c074d12b5212f556375a17741650456a Mon Sep 17 00:00:00 2001 From: wtrocki Date: Thu, 13 Mar 2025 17:13:55 +0100 Subject: [PATCH 7/7] fix: a11ly for severity --- tools/spectral/ipa/rulesets/README.md | 52 +++++++++---------- .../ipa/scripts/generateRulesetReadme.js | 6 +-- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 2b6c5ca3fb..ec0f038b34 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -14,7 +14,7 @@ Rule is based on [http://go/ipa/IPA-5](http://go/ipa/IPA-5). #### xgen-IPA-005-exception-extension-format - ![](https://img.shields.io/badge/error-red) + ![error](https://img.shields.io/badge/error-red) IPA exception extensions must follow the correct format. http://go/ipa/5 @@ -25,12 +25,12 @@ Rule is based on [http://go/ipa/IPA-102](http://go/ipa/IPA-102). #### xgen-IPA-102-path-alternate-resource-name-path-param - ![](https://img.shields.io/badge/error-red) + ![error](https://img.shields.io/badge/error-red) Paths should alternate between resource names and path params. http://go/ipa/102 #### xgen-IPA-102-collection-identifier-camelCase - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) Collection identifiers must be in camelCase. ##### Implementation details @@ -47,7 +47,7 @@ Collection identifiers must be in camelCase. #### xgen-IPA-102-collection-identifier-pattern - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) Collection identifiers must begin with a lowercase letter and contain only ASCII letters and numbers. http://go/ipa/102 @@ -58,32 +58,32 @@ Rule is based on [http://go/ipa/IPA-104](http://go/ipa/IPA-104). #### xgen-IPA-104-resource-has-GET - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) APIs must provide a Get method for resources. http://go/ipa/104 #### xgen-IPA-104-get-method-returns-single-resource - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) The purpose of the Get method is to return data from a single resource. http://go/ipa/104 #### xgen-IPA-104-get-method-response-code-is-200 - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) The Get method must return a 200 OK response. http://go/ipa/104 #### xgen-IPA-104-get-method-returns-response-suffixed-object - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) The Get method of a resource should return a "Response" suffixed object. http://go/ipa/104 #### xgen-IPA-104-get-method-response-has-no-input-fields - ![](https://img.shields.io/badge/warning-yellow) + ![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). http://go/ipa/104 #### xgen-IPA-104-get-method-no-request-body - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) The Get method request must not include a body. http://go/ipa/104 @@ -94,17 +94,17 @@ Rule is based on [http://go/ipa/IPA-105](http://go/ipa/IPA-105). #### xgen-IPA-105-list-method-response-code-is-200 - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) The List method must return a 200 OK response. http://go/ipa/105 #### xgen-IPA-105-list-method-no-request-body - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) The List method request must not include a body. http://go/ipa/105 #### xgen-IPA-105-resource-has-list - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) APIs must provide a List method for resources. http://go/ipa/105 @@ -115,27 +115,27 @@ Rule is based on [http://go/ipa/IPA-106](http://go/ipa/IPA-106). #### xgen-IPA-106-create-method-request-body-is-request-suffixed-object - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) The Create method request should be a Request suffixed object. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. #### xgen-IPA-106-create-method-should-not-have-query-parameters - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) Create operations should not use query parameters. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. #### xgen-IPA-106-create-method-request-body-is-get-method-response - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106 readOnly/writeOnly properties will be ignored. This rule applies only to POST requests targeting resource collection URIs. #### xgen-IPA-106-create-method-request-has-no-readonly-fields - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) Create method Request object must not include fields with readOnly:true. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. #### xgen-IPA-106-create-method-response-code-is-201 - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) Create methods must return a 201 Created response code. http://go/ipa/106 This rule applies only to POST requests targeting resource collection URIs. @@ -146,22 +146,22 @@ Rule is based on [http://go/ipa/IPA-108](http://go/ipa/IPA-108). #### xgen-IPA-108-delete-response-should-be-empty - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) Delete method response should not have schema reference to object. http://go/ipa/108 #### xgen-IPA-108-delete-method-return-204-response - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) DELETE method must return 204 No Content. http://go/ipa/108 #### xgen-IPA-108-delete-include-404-response - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) DELETE method must include 404 response and return it when resource not found. http://go/ipa/108 #### xgen-IPA-108-delete-request-no-body - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) DELETE method must not have request body. http://go/ipa/108 @@ -172,12 +172,12 @@ Rule is based on [http://go/ipa/IPA-109](http://go/ipa/IPA-109). #### xgen-IPA-109-custom-method-must-be-GET-or-POST - ![](https://img.shields.io/badge/error-red) + ![error](https://img.shields.io/badge/error-red) The HTTP method for custom methods must be GET or POST. http://go/ipa/109 #### xgen-IPA-109-custom-method-must-use-camel-case - ![](https://img.shields.io/badge/error-red) + ![error](https://img.shields.io/badge/error-red) The custom method must use camelCase format. http://go/ipa/109 @@ -188,7 +188,7 @@ Rule is based on [http://go/ipa/IPA-113](http://go/ipa/IPA-113). #### xgen-IPA-113-singleton-must-not-have-id - ![](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) Singleton resources must not have a user-provided or system-generated ID. http://go/ipa/113 @@ -199,7 +199,7 @@ Rule is based on [http://go/ipa/IPA-123](http://go/ipa/IPA-123). #### xgen-IPA-123-enum-values-must-be-upper-snake-case - ![](https://img.shields.io/badge/error-red) + ![error](https://img.shields.io/badge/error-red) Enum values must be UPPER_SNAKE_CASE. http://go/ipa/123 diff --git a/tools/spectral/ipa/scripts/generateRulesetReadme.js b/tools/spectral/ipa/scripts/generateRulesetReadme.js index 89c9698c6a..3dd588e557 100644 --- a/tools/spectral/ipa/scripts/generateRulesetReadme.js +++ b/tools/spectral/ipa/scripts/generateRulesetReadme.js @@ -69,11 +69,11 @@ function generateRulesetSections(rules) { function formatSeverity(severity) { switch (severity.toLowerCase()) { case 'info': - return '![](https://img.shields.io/badge/info-green)'; + return '![info](https://img.shields.io/badge/info-green)'; case 'warn': - return '![](https://img.shields.io/badge/warning-yellow)'; + return '![warn](https://img.shields.io/badge/warning-yellow)'; case 'error': - return '![](https://img.shields.io/badge/error-red)'; + return '![error](https://img.shields.io/badge/error-red)'; default: return `\`${severity}\``; }