Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cbaf505
CLOUDP-328955: Switched from ember-inflector to inflection
Jul 3, 2025
eba0010
CLOUDP-328959: Added helper method for stripping custom method names
Jul 4, 2025
06d1ca1
CLOUDP-328959: Implemented basic Operation ID Validation for create o…
Jul 4, 2025
f6ff5dd
CLOUDP-328959: Implemented basic Operation ID Validation for delete o…
Jul 4, 2025
53692d8
CLOUDP-328959: Implemented basic Operation ID Validation for update o…
Jul 4, 2025
98cc8a1
Update tools/spectral/ipa/rulesets/functions/IPA108ValidOperationID.js
sphterry Jul 7, 2025
6360e10
CLOUDP-328959: Fixed error handling pattern
Jul 7, 2025
f47ef0a
CLOUDP-328959: Added more verbose error messages
Jul 7, 2025
5e7a26e
CLOUDP-328959: Added exception handling and removed used variables
Jul 7, 2025
1b8e593
Merge branch 'main' into CLOUDP-328959
Jul 7, 2025
ff9eb08
CLOUDP-328959: 'prettier' new line
Jul 7, 2025
d17c7b6
CLOUDP-328959: Fixed exceptions and imports
Jul 7, 2025
60197ca
CLOUDP-328959: Added opID validation yaml for IPA106 and fixed lint e…
Jul 7, 2025
769a4a0
CLOUDP-328959: Added opID validation yaml for IPA107 and fixed lint e…
Jul 7, 2025
11f4aab
CLOUDP-328959: Added opID validation yaml for IPA108 and fixed lint e…
Jul 7, 2025
ae54d57
CLOUDP-328959: Updated docs
Jul 7, 2025
ff7df80
CLOUDP-328959: Added tests for validating IPA106 valid operationIds
Jul 8, 2025
277cb19
CLOUDP-328959: Added tests for validating IPA108 valid operationIds
Jul 8, 2025
bb78336
CLOUDP-328959: comment out unlaunched test
Jul 8, 2025
fcef3e4
CLOUDP-328959: Added tests for validating IPA107 valid operationIds
Jul 8, 2025
50fa6db
CLOUDP-328959: Added early returns and removed reference to custom me…
Jul 8, 2025
5262142
CLOUDP-328959: Edits
Jul 9, 2025
1eee9f3
Merge branch 'main' into CLOUDP-328959
Jul 9, 2025
ecb2e28
CLOUDP-328959: prettier
Jul 9, 2025
3f4fc95
CLOUDP-328959: doc update
Jul 9, 2025
29c55c4
CLOUDP-328959: Added methodName to functionOptions
Jul 9, 2025
6a9a67d
CLOUDP-328959: Update docs, remove unused schema, add customMethod check
Jul 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
"precommit": "husky install"
},
"jest": {
"transformIgnorePatterns": [
"/node_modules/(?!ember-inflector/)"
],
"transform": {
"^.+\\.[t|j]sx?$": "babel-jest"
},
Expand All @@ -36,6 +33,7 @@
"dotenv": "^17.0.1",
"ember-inflector": "^6.0.0",
"eslint-plugin-jest": "^29.0.1",
"inflection": "^3.0.2",
"markdown-table": "^3.0.4",
"openapi-to-postmanv2": "5.0.0",
"parquet-wasm": "^0.6.1"
Expand All @@ -49,14 +47,14 @@
"aws-sdk-client-mock": "^4.1.0",
"babel-jest": "^30.0.2",
"babel-plugin-transform-import-meta": "^2.3.3",
"brace-expansion": "4.0.1",
"eslint": "^9.30.1",
"eslint-plugin-require-extensions": "^0.1.3",
"globals": "^16.3.0",
"husky": "^9.1.7",
"jest": "^30.0.3",
"lint-staged": "^16.1.2",
"prettier": "3.6.2",
"brace-expansion": "4.0.1"
"prettier": "3.6.2"
},
"engineStrict": false,
"engines": {
Expand Down
34 changes: 34 additions & 0 deletions tools/spectral/ipa/rulesets/functions/IPA106ValidOperationID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { hasException } from './utils/exceptions.js';

Check failure on line 1 in tools/spectral/ipa/rulesets/functions/IPA106ValidOperationID.js

View workflow job for this annotation

GitHub Actions / lint

'hasException' is defined but never used
import { collectAdoption, collectAndReturnViolation } from './utils/collectionUtils.js';
import { isCustomMethodIdentifier, getCustomMethodName, stripCustomMethodName } from './utils/resourceEvaluation.js';
import { generateOperationID } from './utils/operationIdGeneration.js';

const RULE_NAME = 'xgen-IPA-106-valid-operation-id';
const ERROR_MESSAGE = 'Invalid OperationID';

export default (input, _, { path, documentInventory }) => {
let resourcePath = path[1];
const oas = documentInventory.resolved;

Check failure on line 11 in tools/spectral/ipa/rulesets/functions/IPA106ValidOperationID.js

View workflow job for this annotation

GitHub Actions / lint

'oas' is assigned a value but never used
let methodName = 'create';

// TODO detect exceptions

if (isCustomMethodIdentifier(resourcePath)) {
methodName = getCustomMethodName(resourcePath);
resourcePath = stripCustomMethodName(resourcePath);
}

let errors = [];
const expectedOperationID = generateOperationID(methodName, resourcePath);
if (expectedOperationID != input.operationId) {
errors.push({
path: path,
message: `${ERROR_MESSAGE} Found ${input.operationId} expected ${expectedOperationID}.`,
});
}

if (errors.length !== 0) {
return collectAndReturnViolation(path, RULE_NAME, errors);
}
collectAdoption(path, RULE_NAME);
};
34 changes: 34 additions & 0 deletions tools/spectral/ipa/rulesets/functions/IPA107ValidOperationID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { hasException } from './utils/exceptions.js';

Check failure on line 1 in tools/spectral/ipa/rulesets/functions/IPA107ValidOperationID.js

View workflow job for this annotation

GitHub Actions / lint

'hasException' is defined but never used
import { collectAdoption, collectAndReturnViolation } from './utils/collectionUtils.js';
import { isCustomMethodIdentifier, getCustomMethodName, stripCustomMethodName } from './utils/resourceEvaluation.js';
import { generateOperationID } from './utils/operationIdGeneration.js';

const RULE_NAME = 'xgen-IPA-107-valid-operation-id';
const ERROR_MESSAGE = 'Invalid OperationID';

export default (input, _, { path, documentInventory }) => {
let resourcePath = path[1];
const oas = documentInventory.resolved;

Check failure on line 11 in tools/spectral/ipa/rulesets/functions/IPA107ValidOperationID.js

View workflow job for this annotation

GitHub Actions / lint

'oas' is assigned a value but never used
let methodName = 'update';

// TODO detect exceptions

if (isCustomMethodIdentifier(resourcePath)) {
methodName = getCustomMethodName(resourcePath);
resourcePath = stripCustomMethodName(resourcePath);
}

let errors = [];
const expectedOperationID = generateOperationID(methodName, resourcePath);
if (expectedOperationID != input.operationId) {
errors.push({
path: path,
message: `${ERROR_MESSAGE} Found ${input.operationId} expected ${expectedOperationID}.`,
});
}

if (errors.length !== 0) {
return collectAndReturnViolation(path, RULE_NAME, errors);
}
collectAdoption(path, RULE_NAME);
};
34 changes: 34 additions & 0 deletions tools/spectral/ipa/rulesets/functions/IPA108ValidOperationID.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { hasException } from './utils/exceptions.js';

Check failure on line 1 in tools/spectral/ipa/rulesets/functions/IPA108ValidOperationID.js

View workflow job for this annotation

GitHub Actions / lint

'hasException' is defined but never used
import { collectAdoption, collectAndReturnViolation } from './utils/collectionUtils.js';
import { isCustomMethodIdentifier, getCustomMethodName, stripCustomMethodName } from './utils/resourceEvaluation.js';
import { generateOperationID } from './utils/operationIdGeneration.js';

const RULE_NAME = 'xgen-IPA-108-valid-operation-id';
const ERROR_MESSAGE = 'Invalid OperationID';

export default (input, _, { path, documentInventory }) => {
let resourcePath = path[1];
const oas = documentInventory.resolved;

Check failure on line 11 in tools/spectral/ipa/rulesets/functions/IPA108ValidOperationID.js

View workflow job for this annotation

GitHub Actions / lint

'oas' is assigned a value but never used
let methodName = 'delete';

// TODO detect exceptions

if (isCustomMethodIdentifier(resourcePath)) {
methodName = getCustomMethodName(resourcePath);
resourcePath = stripCustomMethodName(resourcePath);
}

let errors = [];
const expectedOperationID = generateOperationID(methodName, resourcePath);
if (expectedOperationID != input.operationId) {
errors.push({
path: path,
message: `${ERROR_MESSAGE} Found ${input.operationId} expected ${expectedOperationID}.`,
});
}

if (errors.length !== 0) {
return collectAndReturnViolation(path, RULE_NAME, errors);
}
collectAdoption(path, RULE_NAME);
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { singularize } from 'ember-inflector';
const inflection = require('inflection');
import { isPathParam, removePrefix, isSingleResourceIdentifier } from './resourceEvaluation.js';

const CAMEL_CASE = /[A-Z]?[a-z]+/g;
Expand Down Expand Up @@ -29,12 +29,12 @@ export function generateOperationID(method, path) {

let opID = verb;
for (let i = 0; i < nouns.length - 1; i++) {
opID += singularize(nouns[i]);
opID += inflection.singularize(nouns[i]);
}

// singularize final noun, dependent on resource identifier
if (isSingleResourceIdentifier(resourceIdentifier) || verb === 'create') {
nouns[nouns.length - 1] = singularize(nouns[nouns.length - 1]);
nouns[nouns.length - 1] = inflection.singularize(nouns[nouns.length - 1]);
}

opID += nouns.pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ export function getCustomMethodName(path) {
return path.split(':')[1];
}

export function stripCustomMethodName(path) {
return path.substring(0, path.indexOf(':'));
}

export function isPathParam(string) {
return string.startsWith('{') && string.endsWith('}');
}
Expand Down
Loading