From 8c45fba89c452049a4f55c01de8437b4fb6e44af Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 14 Mar 2025 15:36:14 +0000 Subject: [PATCH 1/9] CLOUDP-304053: IPA-106:Create - The resource must be the request body (exclude readOnly:true and writeOnly:true) --- ...eateMethodRequestBodyIsGetResponse.test.js | 83 ++--- .../ipa/__tests__/utils/compareUtils.test.js | 284 ++++++++++++------ tools/spectral/ipa/rulesets/IPA-106.yaml | 5 +- tools/spectral/ipa/rulesets/README.md | 3 +- .../createMethodRequestBodyIsGetResponse.js | 23 +- .../rulesets/functions/utils/compareUtils.js | 62 ++-- 6 files changed, 278 insertions(+), 182 deletions(-) diff --git a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js b/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js index 520493d295..7fb64e19d9 100644 --- a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js +++ b/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js @@ -6,13 +6,16 @@ const componentSchemas = { SchemaOne: { type: 'string', }, - SchemaTwo: { + SchemaTwoRequest: { type: 'object', properties: { name: { type: 'string', - readOnly: true, + writeOnly: true, }, + otherThing: { + type: 'string', + } }, }, SchemaThree: { @@ -29,13 +32,16 @@ const componentSchemas = { }, }, }, - SchemaFour: { + SchemaTwoResponse: { type: 'object', properties: { name: { type: 'string', - writeOnly: true, + readOnly: true, }, + otherThing: { + type: 'string', + } }, }, SchemaCircularOne: { @@ -132,12 +138,12 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ content: { 'application/vnd.atlas.2023-01-01+json': { schema: { - $ref: '#/components/schemas/SchemaTwo', + $ref: '#/components/schemas/SchemaTwoRequest', }, }, 'application/vnd.atlas.2024-01-01+json': { schema: { - $ref: '#/components/schemas/SchemaTwo', + $ref: '#/components/schemas/SchemaTwoRequest', }, }, }, @@ -151,7 +157,12 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ content: { 'application/vnd.atlas.2023-01-01+json': { schema: { - $ref: '#/components/schemas/SchemaFour', + $ref: '#/components/schemas/SchemaTwoResponse', + }, + }, + 'application/vnd.atlas.2024-01-01+json': { + schema: { + $ref: '#/components/schemas/SchemaTwoResponse', }, }, }, @@ -244,7 +255,7 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ content: { 'application/vnd.atlas.2023-01-01+json': { schema: { - $ref: '#/components/schemas/SchemaTwo', + $ref: '#/components/schemas/SchemaTwoRequest', }, }, }, @@ -258,12 +269,12 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ content: { 'application/vnd.atlas.2023-01-01+json': { schema: { - $ref: '#/components/schemas/SchemaTwo', + $ref: '#/components/schemas/SchemaTwoResponse', }, }, 'application/vnd.atlas.2024-01-01+json': { schema: { - $ref: '#/components/schemas/SchemaTwo', + $ref: '#/components/schemas/SchemaTwoResponse', }, }, }, @@ -511,14 +522,6 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ 'xgen-IPA-106-create-method-request-body-is-get-method-response': 'reason', }, }, - 'application/vnd.atlas.2024-01-01+json': { - schema: { - $ref: '#/components/schemas/SchemaOne', - }, - 'x-xgen-IPA-exception': { - 'xgen-IPA-106-create-method-request-body-is-get-method-response': 'reason', - }, - }, }, }, }, @@ -530,7 +533,7 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ content: { 'application/vnd.atlas.2023-01-01+json': { schema: { - $ref: '#/components/schemas/SchemaTwo', + $ref: '#/components/schemas/SchemaThree', }, }, }, @@ -544,7 +547,7 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ content: { 'application/vnd.atlas.2023-01-01+json': { schema: { - $ref: '#/components/schemas/SchemaTwo', + $ref: '#/components/schemas/SchemaTwoRequest', }, 'x-xgen-IPA-exception': { 'xgen-IPA-106-create-method-request-body-is-get-method-response': 'reason', @@ -552,7 +555,7 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ }, 'application/vnd.atlas.2024-01-01+json': { schema: { - $ref: '#/components/schemas/SchemaTwo', + $ref: '#/components/schemas/SchemaTwoRequest', }, 'x-xgen-IPA-exception': { 'xgen-IPA-106-create-method-request-body-is-get-method-response': 'reason', @@ -569,43 +572,7 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ content: { 'application/vnd.atlas.2023-01-01+json': { schema: { - $ref: '#/components/schemas/SchemaThree', - }, - }, - }, - }, - }, - }, - }, - '/resourceThree': { - post: { - requestBody: { - content: { - 'application/vnd.atlas.2023-01-01+json': { - schema: { - $ref: '#/components/schemas/SchemaOne', - }, - 'x-xgen-IPA-exception': { - 'xgen-IPA-106-create-method-request-body-is-get-method-response': 'reason', - }, - }, - 'application/vnd.atlas.2024-01-01+json': { - schema: { - $ref: '#/components/schemas/SchemaThree', - }, - }, - }, - }, - }, - }, - '/resourceThree/{id}': { - get: { - responses: { - 200: { - content: { - 'application/vnd.atlas.2023-01-01+json': { - schema: { - $ref: '#/components/schemas/SchemaThree', + $ref: '#/components/schemas/SchemaTwoResponse', }, }, }, diff --git a/tools/spectral/ipa/__tests__/utils/compareUtils.test.js b/tools/spectral/ipa/__tests__/utils/compareUtils.test.js index 3b722616a1..8cb9b5d091 100644 --- a/tools/spectral/ipa/__tests__/utils/compareUtils.test.js +++ b/tools/spectral/ipa/__tests__/utils/compareUtils.test.js @@ -1,5 +1,11 @@ import { describe, expect, it } from '@jest/globals'; -import { isDeepEqual, omitDeep } from '../../rulesets/functions/utils/compareUtils'; +import { + isDeepEqual, + omitDeep, + removePropertyByFlag, + removeReadOnlyProperties, + removeWriteOnlyProperties, +} from '../../rulesets/functions/utils/compareUtils'; describe('isDeepEqual', () => { it('handles primitive values', () => { @@ -55,84 +61,152 @@ describe('isDeepEqual', () => { }); }); -describe('omitDeep', () => { - it('handles primitives', () => { - expect(omitDeep(1, 'any')).toBe(1); - expect(omitDeep('hello', 'any')).toBe('hello'); - expect(omitDeep(null, 'any')).toBe(null); - expect(omitDeep(undefined, 'any')).toBe(undefined); +describe('removePropertyByFlag', () => { + it('handles primitive values', () => { + expect(removePropertyByFlag(1, 'readOnly')).toBe(1); + expect(removePropertyByFlag('hello', 'readOnly')).toBe('hello'); + expect(removePropertyByFlag(true, 'readOnly')).toBe(true); + expect(removePropertyByFlag(null, 'readOnly')).toBe(null); + expect(removePropertyByFlag(undefined, 'readOnly')).toBe(undefined); }); - it('handles shallow objects', () => { - expect(omitDeep({ a: 1, b: 2 }, 'a')).toEqual({ b: 2 }); - expect(omitDeep({ a: 1, b: 2 }, 'c')).toEqual({ a: 1, b: 2 }); - expect(omitDeep({ a: 1, b: 2 }, 'a', 'b')).toEqual({}); + it('handles empty objects', () => { + expect(removePropertyByFlag({}, 'readOnly')).toEqual({}); }); - it('handles arrays', () => { - expect( - omitDeep( - [ - { a: 1, b: 2 }, - { a: 3, b: 4 }, - ], - 'a' - ) - ).toEqual([{ b: 2 }, { b: 4 }]); + it('removes properties with flagged attributes', () => { + const input = { + type: 'object', + properties: { + id: { type: 'string', readOnly: true }, + name: { type: 'string' }, + password: { type: 'string', test: true }, + }, + }; + + const expectedReadOnly = { + type: 'object', + properties: { + name: { type: 'string' }, + password: { type: 'string', test: true }, + }, + }; + + const expectedTest = { + type: 'object', + properties: { + id: { type: 'string', readOnly: true }, + name: { type: 'string' }, + }, + }; + + expect(removePropertyByFlag(input, 'readOnly')).toEqual(expectedReadOnly); + expect(removePropertyByFlag(input, 'test')).toEqual(expectedTest); }); - it('handles nested objects', () => { + it('processes nested objects', () => { const input = { - a: 1, - b: { - c: 2, - d: 3, - e: { - f: 4, - g: 5, + type: 'object', + properties: { + user: { + type: 'object', + properties: { + id: { type: 'string', readOnly: true }, + name: { type: 'string' }, + metadata: { + type: 'object', + properties: { + createdAt: { type: 'string', readOnly: true }, + updatedAt: { type: 'string', readOnly: true }, + notes: { type: 'string' }, + }, + }, + }, }, }, - h: 6, }; const expected = { - a: 1, - b: { - d: 3, - e: { - g: 5, + type: 'object', + properties: { + user: { + type: 'object', + properties: { + name: { type: 'string' }, + metadata: { + type: 'object', + properties: { + notes: { type: 'string' }, + }, + }, + }, }, }, - h: 6, }; - expect(omitDeep(input, 'c', 'f')).toEqual(expected); + expect(removePropertyByFlag(input, 'readOnly')).toEqual(expected); }); - it('handles deeply nested arrays', () => { + it('processes arrays', () => { const input = { - items: [ - { id: 1, name: 'item1', metadata: { created: '2023', readOnly: true } }, - { id: 2, name: 'item2', metadata: { created: '2023', readOnly: true } }, - ], + type: 'array', + items: { + type: 'object', + properties: { + id: { type: 'string', readOnly: true }, + name: { type: 'string' }, + }, + }, }; const expected = { - items: [ - { id: 1, name: 'item1', metadata: { created: '2023' } }, - { id: 2, name: 'item2', metadata: { created: '2023' } }, - ], + type: 'array', + items: { + type: 'object', + properties: { + name: { type: 'string' }, + }, + }, }; - expect(omitDeep(input, 'readOnly')).toEqual(expected); + expect(removePropertyByFlag(input, 'readOnly')).toEqual(expected); }); - it('handles complex schemas', () => { - const schema = { + it('handles array of objects', () => { + const input = [ + { id: 1, readOnly: true }, + { id: 2, name: 'test' }, + { + id: 3, + properties: { + secret: { type: 'string', readOnly: true }, + visible: { type: 'string' }, + }, + }, + ]; + + const expected = [ + { id: 1 }, + { id: 2, name: 'test' }, + { + id: 3, + properties: { + visible: { type: 'string' }, + }, + }, + ]; + + expect(removePropertyByFlag(input, 'readOnly')).toEqual(expected); + }); +}); + +describe('removeReadOnlyProperties', () => { + it('removes readOnly properties from schema', () => { + const input = { type: 'object', properties: { - name: { type: 'string' }, id: { type: 'string', readOnly: true }, + name: { type: 'string' }, details: { type: 'object', properties: { @@ -140,16 +214,6 @@ describe('omitDeep', () => { description: { type: 'string' }, }, }, - items: { - type: 'array', - items: { - type: 'object', - properties: { - itemId: { type: 'string', readOnly: true }, - itemName: { type: 'string' }, - }, - }, - }, }, }; @@ -157,52 +221,96 @@ describe('omitDeep', () => { type: 'object', properties: { name: { type: 'string' }, - id: { type: 'string' }, details: { type: 'object', properties: { - createdAt: { type: 'string' }, description: { type: 'string' }, }, }, - items: { - type: 'array', - items: { - type: 'object', - properties: { - itemId: { type: 'string' }, - itemName: { type: 'string' }, - }, - }, - }, }, }; - expect(omitDeep(schema, 'readOnly')).toEqual(expected); + expect(removeReadOnlyProperties(input)).toEqual(expected); }); +}); - it('handles multiple keys to omit', () => { +describe('removeWriteOnlyProperties', () => { + it('removes writeOnly properties from schema', () => { const input = { - a: 1, - b: 2, - c: { - d: 3, - e: 4, - f: { - g: 5, - h: 6, + type: 'object', + properties: { + id: { type: 'string' }, + password: { type: 'string', writeOnly: true }, + details: { + type: 'object', + properties: { + secretKey: { type: 'string', writeOnly: true }, + description: { type: 'string' }, + }, }, }, }; - expect(omitDeep(input, 'a', 'e', 'g')).toEqual({ - b: 2, - c: { - d: 3, - f: { - h: 6, + const expected = { + type: 'object', + properties: { + id: { type: 'string' }, + details: { + type: 'object', + properties: { + description: { type: 'string' }, + }, }, }, + }; + + expect(removeWriteOnlyProperties(input)).toEqual(expected); + }); +}); + +describe('schema compatibility use cases', () => { + it('request and response schema comparison', () => { + const requestSchema = { + type: 'object', + properties: { + name: { type: 'string' }, + email: { type: 'string' }, + password: { type: 'string', writeOnly: true }, + }, + required: ['name', 'email', 'password'], + }; + + const responseSchema = { + type: 'object', + properties: { + id: { type: 'string', readOnly: true }, + name: { type: 'string' }, + email: { type: 'string' }, + createdAt: { type: 'string', readOnly: true }, + }, + required: ['id', 'name', 'email', 'createdAt'], + }; + + const filteredRequest = removeWriteOnlyProperties(requestSchema); + const filteredResponse = removeReadOnlyProperties(responseSchema); + + // Verify filtered schemas + expect(filteredRequest).toEqual({ + type: 'object', + properties: { + name: { type: 'string' }, + email: { type: 'string' }, + }, + required: ['name', 'email', 'password'], + }); + + expect(filteredResponse).toEqual({ + type: 'object', + properties: { + name: { type: 'string' }, + email: { type: 'string' }, + }, + required: ['id', 'name', 'email', 'createdAt'], }); }); }); diff --git a/tools/spectral/ipa/rulesets/IPA-106.yaml b/tools/spectral/ipa/rulesets/IPA-106.yaml index d04cec321d..b8f82296aa 100644 --- a/tools/spectral/ipa/rulesets/IPA-106.yaml +++ b/tools/spectral/ipa/rulesets/IPA-106.yaml @@ -31,7 +31,8 @@ rules: xgen-IPA-106-create-method-request-body-is-get-method-response: description: >- 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. + readOnly:true properties of Get method response will be ignored. + writeOnly:true properties of Create method request will be ignored. This rule applies only to POST requests targeting resource collection URIs. message: '{{error}} http://go/ipa/106' severity: warn @@ -39,8 +40,6 @@ rules: then: field: '@key' function: 'createMethodRequestBodyIsGetResponse' - functionOptions: - ignoredValues: ['readOnly', 'writeOnly'] xgen-IPA-106-create-method-request-has-no-readonly-fields: description: >- Create method Request object must not include fields with readOnly:true. http://go/ipa/106 diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 56c1dab17d..24e8973dd0 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -101,7 +101,6 @@ The List method request must not include a body. http://go/ipa/105 ![warn](https://img.shields.io/badge/warning-yellow) APIs must provide a List method for resources. http://go/ipa/105 - #### xgen-IPA-105-list-method-response-is-get-method-response ![warn](https://img.shields.io/badge/warning-yellow) @@ -132,7 +131,7 @@ Create operations should not use query parameters. http://go/ipa/106 This rule a #### xgen-IPA-106-create-method-request-body-is-get-method-response ![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. +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:true properties of Get method response will be ignored. writeOnly:true properties of Create method request will be ignored. This rule applies only to POST requests targeting resource collection URIs. #### xgen-IPA-106-create-method-request-has-no-readonly-fields ![warn](https://img.shields.io/badge/warning-yellow) diff --git a/tools/spectral/ipa/rulesets/functions/createMethodRequestBodyIsGetResponse.js b/tools/spectral/ipa/rulesets/functions/createMethodRequestBodyIsGetResponse.js index 8feda5ff13..519ec920f5 100644 --- a/tools/spectral/ipa/rulesets/functions/createMethodRequestBodyIsGetResponse.js +++ b/tools/spectral/ipa/rulesets/functions/createMethodRequestBodyIsGetResponse.js @@ -5,7 +5,7 @@ import { isSingletonResource, } from './utils/resourceEvaluation.js'; import { resolveObject } from './utils/componentUtils.js'; -import { isDeepEqual, omitDeep } from './utils/compareUtils.js'; +import { isDeepEqual, removeReadOnlyProperties, removeWriteOnlyProperties } from './utils/compareUtils.js'; import { hasException } from './utils/exceptions.js'; import { collectAdoption, collectAndReturnViolation, collectException } from './utils/collectionUtils.js'; import { getResponseOfGetMethodByMediaType } from './utils/methodUtils.js'; @@ -14,7 +14,7 @@ const RULE_NAME = 'xgen-IPA-106-create-method-request-body-is-get-method-respons const ERROR_MESSAGE = 'The request body schema properties must match the response body schema properties of the Get method.'; -export default (input, opts, { path, documentInventory }) => { +export default (input, _, { path, documentInventory }) => { const oas = documentInventory.resolved; const resourcePath = path[1]; let mediaType = input; @@ -42,8 +42,7 @@ export default (input, opts, { path, documentInventory }) => { const errors = checkViolationsAndReturnErrors( path, postMethodRequestContentPerMediaType, - getMethodResponseContentPerMediaType, - opts + getMethodResponseContentPerMediaType ); if (errors.length !== 0) { @@ -56,12 +55,10 @@ export default (input, opts, { path, documentInventory }) => { function checkViolationsAndReturnErrors( path, postMethodRequestContentPerMediaType, - getMethodResponseContentPerMediaType, - opts + getMethodResponseContentPerMediaType ) { const errors = []; - const ignoredValues = opts?.ignoredValues || []; if (!getMethodResponseContentPerMediaType.schema) { return [ { @@ -70,12 +67,12 @@ function checkViolationsAndReturnErrors( }, ]; } - if ( - !isDeepEqual( - omitDeep(postMethodRequestContentPerMediaType.schema, ...ignoredValues), - omitDeep(getMethodResponseContentPerMediaType.schema, ...ignoredValues) - ) - ) { + + // Create filtered versions of schemas by removing properties with appropriate flags + const filteredCreateRequestSchema = removeWriteOnlyProperties(postMethodRequestContentPerMediaType); + const filteredGetResponseSchema = removeReadOnlyProperties(getMethodResponseContentPerMediaType); + + if (!isDeepEqual(filteredCreateRequestSchema, filteredGetResponseSchema)) { errors.push({ path, message: ERROR_MESSAGE, diff --git a/tools/spectral/ipa/rulesets/functions/utils/compareUtils.js b/tools/spectral/ipa/rulesets/functions/utils/compareUtils.js index 57d20ee327..888255c5b9 100644 --- a/tools/spectral/ipa/rulesets/functions/utils/compareUtils.js +++ b/tools/spectral/ipa/rulesets/functions/utils/compareUtils.js @@ -34,31 +34,57 @@ export function isDeepEqual(value1, value2) { } /** - * Deep clone an object while omitting specific properties - * @param {object} obj Object to clone and omit properties from - * @param {...string} keys Properties to omit - * @returns {object} New object without the specified properties + * Recursively removes properties with given flags from schema + * @param {object} schema The schema to process + * @param {string} propertyToRemove The property type to remove (boolean property) + * @returns {object} New schema with specified properties removed */ -export function omitDeep(obj, ...keys) { - if (!obj || typeof obj !== 'object') return obj; +export function removePropertyByFlag(schema, propertyToRemove) { + if (!schema || typeof schema !== 'object') return schema; - // Handle arrays - if (Array.isArray(obj)) { - return obj.map((item) => omitDeep(item, ...keys)); + if (Array.isArray(schema)) { + return schema.map((item) => removePropertyByFlag(item, propertyToRemove)); } - // Handle regular objects - return Object.entries(obj).reduce((result, [key, value]) => { - // Skip properties that should be omitted - if (keys.includes(key)) return result; + const result = {}; - // Handle nested objects/arrays recursively - if (value && typeof value === 'object') { - result[key] = omitDeep(value, ...keys); + // Handle regular object properties + for (const [key, value] of Object.entries(schema)) { + // Skip this property if it's marked with the flag we're removing + if (key === propertyToRemove && value === true) continue; + + // Handle properties object specially + if (key === 'properties' && typeof value === 'object') { + result[key] = {}; + for (const [propName, propValue] of Object.entries(value)) { + // Skip properties marked with the flag we're removing + if (propValue[propertyToRemove] === true) continue; + result[key][propName] = removePropertyByFlag(propValue, propertyToRemove); + } + } else if (typeof value === 'object') { + result[key] = removePropertyByFlag(value, propertyToRemove); } else { result[key] = value; } + } + + return result; +} + +/** + * Recursively removes properties with readOnly: true flag from schema + * @param {object} schema The schema to process + * @returns {object} New schema with readOnly properties removed + */ +export function removeReadOnlyProperties(schema) { + return removePropertyByFlag(schema, 'readOnly'); +} - return result; - }, {}); +/** + * Recursively removes properties with writeOnly: true flag from schema + * @param {object} schema The schema to process + * @returns {object} New schema with writeOnly properties removed + */ +export function removeWriteOnlyProperties(schema) { + return removePropertyByFlag(schema, 'writeOnly'); } From a562bab419f265e542b46472d3853ce30a622704 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 14 Mar 2025 15:40:47 +0000 Subject: [PATCH 2/9] prettier fix --- ...eateMethodRequestBodyIsGetResponse.test.js | 4 +- tools/spectral/ipa/rulesets/README.md | 124 ++++++++++-------- 2 files changed, 69 insertions(+), 59 deletions(-) diff --git a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js b/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js index 7fb64e19d9..137eb8c4d0 100644 --- a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js +++ b/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js @@ -15,7 +15,7 @@ const componentSchemas = { }, otherThing: { type: 'string', - } + }, }, }, SchemaThree: { @@ -41,7 +41,7 @@ const componentSchemas = { }, otherThing: { type: 'string', - } + }, }, }, SchemaCircularOne: { diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 24e8973dd0..2cbdc9bc65 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -14,16 +14,16 @@ Rule is based on [http://go/ipa/IPA-5](http://go/ipa/IPA-5). #### xgen-IPA-005-exception-extension-format - ![error](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 ##### Implementation details -Rule checks for the following conditions: - - Exception rule names must start with 'xgen-IPA-' prefix - - Each exception must include a non-empty reason as a string - - This rule itself does not allow exceptions +Rule checks for the following conditions: +- Exception rule names must start with 'xgen-IPA-' prefix +- Each exception must include a non-empty reason as a string +- This rule itself does not allow exceptions ### IPA-102 @@ -31,90 +31,99 @@ Rule is based on [http://go/ipa/IPA-102](http://go/ipa/IPA-102). #### xgen-IPA-102-path-alternate-resource-name-path-param - ![error](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 - ![warn](https://img.shields.io/badge/warning-yellow) +![warn](https://img.shields.io/badge/warning-yellow) Collection identifiers must be in camelCase. - ##### Implementation details - Rule checks for the following conditions: +##### Implementation details - - 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 +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 #### xgen-IPA-102-collection-identifier-pattern - ![warn](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 - ### IPA-104 Rule is based on [http://go/ipa/IPA-104](http://go/ipa/IPA-104). #### xgen-IPA-104-resource-has-GET - ![warn](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 - ![warn](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 - ![warn](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 - ![warn](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 - ![warn](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 - ![warn](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 - ### 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 - ![warn](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 - ![warn](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 - ![warn](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 + #### xgen-IPA-105-list-method-response-is-get-method-response - ![warn](https://img.shields.io/badge/warning-yellow) +![warn](https://img.shields.io/badge/warning-yellow) The response body of the List method should consist of the same resource object returned by the Get method. http://go/ipa/105 + ##### Implementation details -Validation checks that the List method response contains items property with reference to the same schema as the Get method response. - - Validation applies to List methods for resource collections only - - Validation applies to json response content only - - Validation ignores responses without schema and non-paginated responses - - A response is considered paginated if it contains an array property named `results` - - Validation ignores resources without a Get method - - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation +Validation checks that the List method response contains items property with reference to the same schema as the Get method response. +- Validation applies to List methods for resource collections only +- Validation applies to json response content only +- Validation ignores responses without schema and non-paginated responses + - A response is considered paginated if it contains an array property named `results` +- Validation ignores resources without a Get method +- Paths with `x-xgen-IPA-exception` for this rule are excluded from validation ### IPA-106 @@ -122,80 +131,81 @@ 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 - ![warn](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 - ![warn](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 - ![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:true properties of Get method response will be ignored. writeOnly:true properties of Create method request will be ignored. This rule applies only to POST requests targeting resource collection URIs. +![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:true properties of Get method response will be ignored. writeOnly:true properties of Create method request will be ignored. This rule applies only to POST requests targeting resource collection URIs. + #### xgen-IPA-106-create-method-request-has-no-readonly-fields - ![warn](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 - ![warn](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. - ### IPA-108 Rule is based on [http://go/ipa/IPA-108](http://go/ipa/IPA-108). #### xgen-IPA-108-delete-response-should-be-empty - ![warn](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 - ![warn](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 - ![warn](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 - ![warn](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 - ### 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 - ![error](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 - ![error](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 - ### IPA-113 Rule is based on [http://go/ipa/IPA-113](http://go/ipa/IPA-113). #### xgen-IPA-113-singleton-must-not-have-id - ![warn](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 - ### 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 - ![error](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 - - - From 53ba63d6369ead861fc9baba525273c8bda3ed60 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 14 Mar 2025 15:42:10 +0000 Subject: [PATCH 3/9] ipa docs fix --- tools/spectral/ipa/rulesets/README.md | 124 ++++++++++++-------------- 1 file changed, 57 insertions(+), 67 deletions(-) diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 2cbdc9bc65..24e8973dd0 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -14,16 +14,16 @@ Rule is based on [http://go/ipa/IPA-5](http://go/ipa/IPA-5). #### xgen-IPA-005-exception-extension-format -![error](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 ##### Implementation details - Rule checks for the following conditions: + - Exception rule names must start with 'xgen-IPA-' prefix + - Each exception must include a non-empty reason as a string + - This rule itself does not allow exceptions + -- Exception rule names must start with 'xgen-IPA-' prefix -- Each exception must include a non-empty reason as a string -- This rule itself does not allow exceptions ### IPA-102 @@ -31,99 +31,90 @@ Rule is based on [http://go/ipa/IPA-102](http://go/ipa/IPA-102). #### xgen-IPA-102-path-alternate-resource-name-path-param -![error](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 -![warn](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) Collection identifiers must be in camelCase. -##### Implementation details + ##### Implementation details + Rule checks for the following conditions: -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 + - 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 #### xgen-IPA-102-collection-identifier-pattern -![warn](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 + ### IPA-104 Rule is based on [http://go/ipa/IPA-104](http://go/ipa/IPA-104). #### xgen-IPA-104-resource-has-GET -![warn](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 -![warn](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 -![warn](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 -![warn](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 -![warn](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 -![warn](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 + ### 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 -![warn](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 -![warn](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 -![warn](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 - #### xgen-IPA-105-list-method-response-is-get-method-response -![warn](https://img.shields.io/badge/warning-yellow) + ![warn](https://img.shields.io/badge/warning-yellow) The response body of the List method should consist of the same resource object returned by the Get method. http://go/ipa/105 - ##### Implementation details - Validation checks that the List method response contains items property with reference to the same schema as the Get method response. -- Validation applies to List methods for resource collections only -- Validation applies to json response content only -- Validation ignores responses without schema and non-paginated responses - - A response is considered paginated if it contains an array property named `results` -- Validation ignores resources without a Get method -- Paths with `x-xgen-IPA-exception` for this rule are excluded from validation + - Validation applies to List methods for resource collections only + - Validation applies to json response content only + - Validation ignores responses without schema and non-paginated responses + - A response is considered paginated if it contains an array property named `results` + - Validation ignores resources without a Get method + - Paths with `x-xgen-IPA-exception` for this rule are excluded from validation + ### IPA-106 @@ -131,81 +122,80 @@ 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 -![warn](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 -![warn](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 -![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:true properties of Get method response will be ignored. writeOnly:true properties of Create method request will be ignored. This rule applies only to POST requests targeting resource collection URIs. - + ![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:true properties of Get method response will be ignored. writeOnly:true properties of Create method request will be ignored. This rule applies only to POST requests targeting resource collection URIs. #### xgen-IPA-106-create-method-request-has-no-readonly-fields -![warn](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 -![warn](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. + ### IPA-108 Rule is based on [http://go/ipa/IPA-108](http://go/ipa/IPA-108). #### xgen-IPA-108-delete-response-should-be-empty -![warn](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 -![warn](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 -![warn](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 -![warn](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 + ### 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 -![error](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 -![error](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 + ### IPA-113 Rule is based on [http://go/ipa/IPA-113](http://go/ipa/IPA-113). #### xgen-IPA-113-singleton-must-not-have-id -![warn](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 + ### 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 -![error](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 + + + From 94b80e1c82bb8f06cc68778e961e37a121aa8f85 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 14 Mar 2025 15:59:50 +0000 Subject: [PATCH 4/9] ipa docs fix --- tools/spectral/ipa/rulesets/IPA-106.yaml | 39 ++++++++++++++++-------- tools/spectral/ipa/rulesets/README.md | 20 +++++++++--- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/tools/spectral/ipa/rulesets/IPA-106.yaml b/tools/spectral/ipa/rulesets/IPA-106.yaml index b8f82296aa..93e1583bf6 100644 --- a/tools/spectral/ipa/rulesets/IPA-106.yaml +++ b/tools/spectral/ipa/rulesets/IPA-106.yaml @@ -12,8 +12,11 @@ rules: xgen-IPA-106-create-method-request-body-is-request-suffixed-object: description: >- 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. - message: '{{error}} http://go/ipa/106' + + ##### Implementation details + + Validation checks the POST method for resource collection paths. + message: '{{error}} http://go/ipa-spectral#IPA-106' severity: warn given: '$.paths[*].post.requestBody.content' then: @@ -22,8 +25,11 @@ rules: xgen-IPA-106-create-method-should-not-have-query-parameters: description: >- Create operations should not use query parameters. http://go/ipa/106 - This rule applies only to POST requests targeting resource collection URIs. - message: '{{error}} http://go/ipa/106' + + ##### Implementation details + + Validation checks the POST method for resource collection paths. + message: '{{error}} http://go/ipa-spectral#IPA-106' severity: warn given: '$.paths[*].post' then: @@ -31,10 +37,13 @@ rules: xgen-IPA-106-create-method-request-body-is-get-method-response: description: >- 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:true properties of Get method response will be ignored. - writeOnly:true properties of Create method request will be ignored. - This rule applies only to POST requests targeting resource collection URIs. - message: '{{error}} http://go/ipa/106' + + ##### Implementation details + + Validation checks the POST method for resource collection paths. + - `readOnly:true` properties of Get method response will be ignored. + - `writeOnly:true` properties of Create method request will be ignored. + message: '{{error}} http://go/ipa-spectral#IPA-106' severity: warn given: '$.paths[*].post.requestBody.content' then: @@ -43,8 +52,11 @@ rules: xgen-IPA-106-create-method-request-has-no-readonly-fields: description: >- 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. - message: '{{error}} http://go/ipa/106' + + ##### Implementation details + + Validation checks the POST method for resource collection paths. + message: '{{error}} http://go/ipa-spectral#IPA-106' severity: warn given: '$.paths[*].post.requestBody.content' then: @@ -53,8 +65,11 @@ rules: xgen-IPA-106-create-method-response-code-is-201: description: >- Create methods must return a 201 Created response code. http://go/ipa/106 - This rule applies only to POST requests targeting resource collection URIs. - message: '{{error}} http://go/ipa/106' + + ##### Implementation details + + Validation checks the POST method for resource collection paths. + message: '{{error}} http://go/ipa-spectral#IPA-106' severity: warn given: '$.paths[*].post' then: diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 24e8973dd0..76e1ac5436 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -123,23 +123,33 @@ 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 ![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. +The Create method request should be a Request suffixed object. http://go/ipa/106 +##### Implementation details +Validation checks the POST method for resource collection paths. #### xgen-IPA-106-create-method-should-not-have-query-parameters ![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. +Create operations should not use query parameters. http://go/ipa/106 +##### Implementation details +Validation checks the POST method for resource collection paths. #### xgen-IPA-106-create-method-request-body-is-get-method-response ![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:true properties of Get method response will be ignored. writeOnly:true properties of Create method request will be ignored. This rule applies only to POST requests targeting resource collection URIs. +Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106 +##### Implementation details +Validation checks the POST method for resource collection paths. - `readOnly:true` properties of Get method response will be ignored. - `writeOnly:true` properties of Create method request will be ignored. #### xgen-IPA-106-create-method-request-has-no-readonly-fields ![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. +Create method Request object must not include fields with readOnly:true. http://go/ipa/106 +##### Implementation details +Validation checks the POST method for resource collection paths. #### xgen-IPA-106-create-method-response-code-is-201 ![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. +Create methods must return a 201 Created response code. http://go/ipa/106 +##### Implementation details +Validation checks the POST method for resource collection paths. ### IPA-108 From f97156f55bdea3a515441de375f5f301782cdb78 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 14 Mar 2025 16:00:42 +0000 Subject: [PATCH 5/9] ipa docs fix --- tools/spectral/ipa/rulesets/IPA-106.yaml | 4 ++-- tools/spectral/ipa/rulesets/README.md | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/spectral/ipa/rulesets/IPA-106.yaml b/tools/spectral/ipa/rulesets/IPA-106.yaml index 93e1583bf6..12c4c03eb1 100644 --- a/tools/spectral/ipa/rulesets/IPA-106.yaml +++ b/tools/spectral/ipa/rulesets/IPA-106.yaml @@ -41,8 +41,8 @@ rules: ##### Implementation details Validation checks the POST method for resource collection paths. - - `readOnly:true` properties of Get method response will be ignored. - - `writeOnly:true` properties of Create method request will be ignored. + - `readOnly:true` properties of Get method response will be ignored. + - `writeOnly:true` properties of Create method request will be ignored. message: '{{error}} http://go/ipa-spectral#IPA-106' severity: warn given: '$.paths[*].post.requestBody.content' diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 76e1ac5436..8c1f4878fd 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -137,7 +137,9 @@ Validation checks the POST method for resource collection paths. ![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 ##### Implementation details -Validation checks the POST method for resource collection paths. - `readOnly:true` properties of Get method response will be ignored. - `writeOnly:true` properties of Create method request will be ignored. +Validation checks the POST method for resource collection paths. + - `readOnly:true` properties of Get method response will be ignored. + - `writeOnly:true` properties of Create method request will be ignored. #### xgen-IPA-106-create-method-request-has-no-readonly-fields ![warn](https://img.shields.io/badge/warning-yellow) From ed59c19444d03da3234bee87b336031466d03896 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 14 Mar 2025 16:04:09 +0000 Subject: [PATCH 6/9] ipa docs fix --- ...eateMethodRequestBodyIsGetResponse.test.js | 20 +++++++++---------- ...RequestBodyIsRequestSuffixedObject.test.js | 10 +++++----- ...teMethodRequestHasNoReadonlyFields.test.js | 8 ++++---- ...eateMethodResponseCodeIs201Created.test.js | 6 +++--- ...MethodShouldNotHaveQueryParameters.test.js | 6 +++--- tools/spectral/ipa/rulesets/IPA-106.yaml | 12 +++++------ tools/spectral/ipa/rulesets/README.md | 10 +++++----- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js b/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js index 137eb8c4d0..640e55a4ac 100644 --- a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js +++ b/tools/spectral/ipa/__tests__/createMethodRequestBodyIsGetResponse.test.js @@ -393,56 +393,56 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ { code: 'xgen-IPA-106-create-method-request-body-is-get-method-response', message: - 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa/106', + 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-get-method-response', message: - 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa/106', + 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-get-method-response', message: - 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa/106', + 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-get-method-response', message: - 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa/106', + 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-get-method-response', message: - 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa/106', + 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceThree', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-get-method-response', message: - 'Could not validate that the Create request body schema matches the response schema of the Get method. The Get method does not have a schema. http://go/ipa/106', + 'Could not validate that the Create request body schema matches the response schema of the Get method. The Get method does not have a schema. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceFour', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-get-method-response', message: - 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa/106', + 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceCircular', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-get-method-response', message: - 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa/106', + 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceCircular', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'], severity: DiagnosticSeverity.Warning, }, @@ -492,14 +492,14 @@ testRule('xgen-IPA-106-create-method-request-body-is-get-method-response', [ { code: 'xgen-IPA-106-create-method-request-body-is-get-method-response', message: - 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa/106', + 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106', path: ['paths', '/animalResource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-get-method-response', message: - 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa/106', + 'The request body schema properties must match the response body schema properties of the Get method. http://go/ipa-spectral#IPA-106', path: ['paths', '/animalResource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js b/tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js index 6f6164d26f..1587c055ce 100644 --- a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js +++ b/tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js @@ -154,31 +154,31 @@ testRule('xgen-IPA-106-create-method-request-body-is-request-suffixed-object', [ errors: [ { code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object', - message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa/106', + message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object', - message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa/106', + message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object', - message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa/106', + message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object', - message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa/106', + message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object', - message: 'The response body schema is defined inline and must reference a predefined schema. http://go/ipa/106', + message: 'The response body schema is defined inline and must reference a predefined schema. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceThree', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/__tests__/createMethodRequestHasNoReadonlyFields.test.js b/tools/spectral/ipa/__tests__/createMethodRequestHasNoReadonlyFields.test.js index 7e73746b7e..58c98dd8af 100644 --- a/tools/spectral/ipa/__tests__/createMethodRequestHasNoReadonlyFields.test.js +++ b/tools/spectral/ipa/__tests__/createMethodRequestHasNoReadonlyFields.test.js @@ -152,14 +152,14 @@ testRule('xgen-IPA-106-create-method-request-has-no-readonly-fields', [ { code: 'xgen-IPA-106-create-method-request-has-no-readonly-fields', message: - 'The Create method request object must not include input fields (readOnly properties). Found readOnly property at: id. http://go/ipa/106', + 'The Create method request object must not include input fields (readOnly properties). Found readOnly property at: id. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-has-no-readonly-fields', message: - 'The Create method request object must not include input fields (readOnly properties). Found readOnly property at one of the inline schemas. http://go/ipa/106', + 'The Create method request object must not include input fields (readOnly properties). Found readOnly property at one of the inline schemas. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'], severity: DiagnosticSeverity.Warning, }, @@ -192,7 +192,7 @@ testRule('xgen-IPA-106-create-method-request-has-no-readonly-fields', [ { code: 'xgen-IPA-106-create-method-request-has-no-readonly-fields', message: - 'The Create method request object must not include input fields (readOnly properties). Found readOnly property at: user.userId. http://go/ipa/106', + 'The Create method request object must not include input fields (readOnly properties). Found readOnly property at: user.userId. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, @@ -225,7 +225,7 @@ testRule('xgen-IPA-106-create-method-request-has-no-readonly-fields', [ { code: 'xgen-IPA-106-create-method-request-has-no-readonly-fields', message: - 'The Create method request object must not include input fields (readOnly properties). Found readOnly property at: items.items.itemId. http://go/ipa/106', + 'The Create method request object must not include input fields (readOnly properties). Found readOnly property at: items.items.itemId. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/__tests__/createMethodResponseCodeIs201Created.test.js b/tools/spectral/ipa/__tests__/createMethodResponseCodeIs201Created.test.js index 2cfc382847..34d21ff71f 100644 --- a/tools/spectral/ipa/__tests__/createMethodResponseCodeIs201Created.test.js +++ b/tools/spectral/ipa/__tests__/createMethodResponseCodeIs201Created.test.js @@ -74,21 +74,21 @@ testRule('xgen-IPA-106-create-method-response-code-is-201', [ { code: 'xgen-IPA-106-create-method-response-code-is-201', message: - 'The Create method must return a 201 Created response. This method either lacks a 201 Created response or defines a different 2xx status code. http://go/ipa/106', + 'The Create method must return a 201 Created response. This method either lacks a 201 Created response or defines a different 2xx status code. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceOne', 'post'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-response-code-is-201', message: - 'The Create method must return a 201 Created response. This method either lacks a 201 Created response or defines a different 2xx status code. http://go/ipa/106', + 'The Create method must return a 201 Created response. This method either lacks a 201 Created response or defines a different 2xx status code. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-response-code-is-201', message: - 'The Create method must return a 201 Created response. This method either lacks a 201 Created response or defines a different 2xx status code. http://go/ipa/106', + 'The Create method must return a 201 Created response. This method either lacks a 201 Created response or defines a different 2xx status code. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceThree', 'post'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js b/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js index b6244093ed..e25f3fb0fd 100644 --- a/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js +++ b/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js @@ -120,20 +120,20 @@ testRule('xgen-IPA-106-create-method-should-not-have-query-parameters', [ errors: [ { code: 'xgen-IPA-106-create-method-should-not-have-query-parameters', - message: 'Input parameter [filter]: Create operations should not have query parameters. http://go/ipa/106', + message: 'Input parameter [filter]: Create operations should not have query parameters. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-should-not-have-query-parameters', - message: 'Input parameter [query-param]: Create operations should not have query parameters. http://go/ipa/106', + message: 'Input parameter [query-param]: Create operations should not have query parameters. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-should-not-have-query-parameters', message: - 'Input parameter [query-param-2]: Create operations should not have query parameters. http://go/ipa/106', + 'Input parameter [query-param-2]: Create operations should not have query parameters. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/rulesets/IPA-106.yaml b/tools/spectral/ipa/rulesets/IPA-106.yaml index 12c4c03eb1..e506d79f67 100644 --- a/tools/spectral/ipa/rulesets/IPA-106.yaml +++ b/tools/spectral/ipa/rulesets/IPA-106.yaml @@ -1,5 +1,5 @@ # IPA-106: Create -# http://go/ipa/106 +# http://go/ipa-spectral#IPA-106 functions: - createMethodRequestBodyIsRequestSuffixedObject @@ -11,7 +11,7 @@ functions: rules: xgen-IPA-106-create-method-request-body-is-request-suffixed-object: description: >- - The Create method request should be a Request suffixed object. http://go/ipa/106 + The Create method request should be a Request suffixed object. ##### Implementation details @@ -24,7 +24,7 @@ rules: function: 'createMethodRequestBodyIsRequestSuffixedObject' xgen-IPA-106-create-method-should-not-have-query-parameters: description: >- - Create operations should not use query parameters. http://go/ipa/106 + Create operations should not use query parameters. ##### Implementation details @@ -36,7 +36,7 @@ rules: function: 'createMethodShouldNotHaveQueryParameters' xgen-IPA-106-create-method-request-body-is-get-method-response: description: >- - Request body content of the Create method and response content of the Get method should refer to the same resource. http://go/ipa/106 + Request body content of the Create method and response content of the Get method should refer to the same resource. ##### Implementation details @@ -51,7 +51,7 @@ rules: function: 'createMethodRequestBodyIsGetResponse' xgen-IPA-106-create-method-request-has-no-readonly-fields: description: >- - Create method Request object must not include fields with readOnly:true. http://go/ipa/106 + Create method Request object must not include fields with readOnly:true. ##### Implementation details @@ -64,7 +64,7 @@ rules: function: 'createMethodRequestHasNoReadonlyFields' xgen-IPA-106-create-method-response-code-is-201: description: >- - Create methods must return a 201 Created response code. http://go/ipa/106 + Create methods must return a 201 Created response code. ##### Implementation details diff --git a/tools/spectral/ipa/rulesets/README.md b/tools/spectral/ipa/rulesets/README.md index 8c1f4878fd..5dd913d5be 100644 --- a/tools/spectral/ipa/rulesets/README.md +++ b/tools/spectral/ipa/rulesets/README.md @@ -123,19 +123,19 @@ 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 ![warn](https://img.shields.io/badge/warning-yellow) -The Create method request should be a Request suffixed object. http://go/ipa/106 +The Create method request should be a Request suffixed object. ##### Implementation details Validation checks the POST method for resource collection paths. #### xgen-IPA-106-create-method-should-not-have-query-parameters ![warn](https://img.shields.io/badge/warning-yellow) -Create operations should not use query parameters. http://go/ipa/106 +Create operations should not use query parameters. ##### Implementation details Validation checks the POST method for resource collection paths. #### xgen-IPA-106-create-method-request-body-is-get-method-response ![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 +Request body content of the Create method and response content of the Get method should refer to the same resource. ##### Implementation details Validation checks the POST method for resource collection paths. - `readOnly:true` properties of Get method response will be ignored. @@ -143,13 +143,13 @@ Validation checks the POST method for resource collection paths. #### xgen-IPA-106-create-method-request-has-no-readonly-fields ![warn](https://img.shields.io/badge/warning-yellow) -Create method Request object must not include fields with readOnly:true. http://go/ipa/106 +Create method Request object must not include fields with readOnly:true. ##### Implementation details Validation checks the POST method for resource collection paths. #### xgen-IPA-106-create-method-response-code-is-201 ![warn](https://img.shields.io/badge/warning-yellow) -Create methods must return a 201 Created response code. http://go/ipa/106 +Create methods must return a 201 Created response code. ##### Implementation details Validation checks the POST method for resource collection paths. From 27344246e480705bb771532e62d1e1e98c657e35 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 14 Mar 2025 16:06:32 +0000 Subject: [PATCH 7/9] prettier fix --- ...thodRequestBodyIsRequestSuffixedObject.test.js | 15 ++++++++++----- ...eateMethodShouldNotHaveQueryParameters.test.js | 6 ++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js b/tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js index 1587c055ce..fa73dba7f7 100644 --- a/tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js +++ b/tools/spectral/ipa/__tests__/createMethodRequestBodyIsRequestSuffixedObject.test.js @@ -154,31 +154,36 @@ testRule('xgen-IPA-106-create-method-request-body-is-request-suffixed-object', [ errors: [ { code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object', - message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', + message: + 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object', - message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', + message: + 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object', - message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', + message: + 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object', - message: 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', + message: + 'The response body schema must reference a schema with a Request suffix. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post', 'requestBody', 'content', 'application/vnd.atlas.2024-01-01+json'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-request-body-is-request-suffixed-object', - message: 'The response body schema is defined inline and must reference a predefined schema. http://go/ipa-spectral#IPA-106', + message: + 'The response body schema is defined inline and must reference a predefined schema. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceThree', 'post', 'requestBody', 'content', 'application/vnd.atlas.2023-01-01+json'], severity: DiagnosticSeverity.Warning, }, diff --git a/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js b/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js index e25f3fb0fd..494cc6b98c 100644 --- a/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js +++ b/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js @@ -120,13 +120,15 @@ testRule('xgen-IPA-106-create-method-should-not-have-query-parameters', [ errors: [ { code: 'xgen-IPA-106-create-method-should-not-have-query-parameters', - message: 'Input parameter [filter]: Create operations should not have query parameters. http://go/ipa-spectral#IPA-106', + message: + 'Input parameter [filter]: Create operations should not have query parameters. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-should-not-have-query-parameters', - message: 'Input parameter [query-param]: Create operations should not have query parameters. http://go/ipa-spectral#IPA-106', + message: + 'Input parameter [query-param]: Create operations should not have query parameters. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post'], severity: DiagnosticSeverity.Warning, }, From f90c13c3c753338a7071dcb477e1b1453bf16b52 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 14 Mar 2025 16:16:02 +0000 Subject: [PATCH 8/9] prettier fix --- .../createMethodShouldNotHaveQueryParameters.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js b/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js index 59ce2f3081..1b3b6a3f37 100644 --- a/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js +++ b/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js @@ -120,19 +120,19 @@ testRule('xgen-IPA-106-create-method-should-not-have-query-parameters', [ errors: [ { code: 'xgen-IPA-106-create-method-should-not-have-query-parameters', - message: 'Create operations should not have query parameters. Found [filter]. http://go/ipa/106', + message: 'Create operations should not have query parameters. Found [filter]. http://go/ipa-spectral#IPA-106', path: ['paths', '/resource', 'post'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-should-not-have-query-parameters', - message: 'Create operations should not have query parameters. Found [query-param]. http://go/ipa/106', + message: 'Create operations should not have query parameters. Found [query-param]. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-should-not-have-query-parameters', - message: 'Create operations should not have query parameters. Found [query-param-2]. http://go/ipa/106', + message: 'Create operations should not have query parameters. Found [query-param-2]. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post'], severity: DiagnosticSeverity.Warning, }, From 31a6a80112724ae22a43c39a990d783f894b4694 Mon Sep 17 00:00:00 2001 From: Yeliz Henden Date: Fri, 14 Mar 2025 16:20:56 +0000 Subject: [PATCH 9/9] prettier fix --- .../createMethodShouldNotHaveQueryParameters.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js b/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js index 1b3b6a3f37..8346a7a4b8 100644 --- a/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js +++ b/tools/spectral/ipa/__tests__/createMethodShouldNotHaveQueryParameters.test.js @@ -126,13 +126,15 @@ testRule('xgen-IPA-106-create-method-should-not-have-query-parameters', [ }, { code: 'xgen-IPA-106-create-method-should-not-have-query-parameters', - message: 'Create operations should not have query parameters. Found [query-param]. http://go/ipa-spectral#IPA-106', + message: + 'Create operations should not have query parameters. Found [query-param]. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post'], severity: DiagnosticSeverity.Warning, }, { code: 'xgen-IPA-106-create-method-should-not-have-query-parameters', - message: 'Create operations should not have query parameters. Found [query-param-2]. http://go/ipa-spectral#IPA-106', + message: + 'Create operations should not have query parameters. Found [query-param-2]. http://go/ipa-spectral#IPA-106', path: ['paths', '/resourceTwo', 'post'], severity: DiagnosticSeverity.Warning, },