Skip to content

feat(ibm-operationid-naming-convention): extend operationid naming check - #757

Merged
diatrcz merged 4 commits into
mainfrom
lt/operation-id-naming
Aug 27, 2025
Merged

feat(ibm-operationid-naming-convention): extend operationid naming check#757
diatrcz merged 4 commits into
mainfrom
lt/operation-id-naming

Conversation

@diatrcz

@diatrcz diatrcz commented Aug 14, 2025

Copy link
Copy Markdown
Contributor

Extends the ibm-operationid-naming-convention rule so now it checks if operation IDs follow the handbook naming convention rule or not.

PR Checklist

General checklist

Please make sure that your PR fulfills the following requirements:

  • The commit message follows the Angular Commit Message Guidelines.
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Dependencies have been updated as needed
  • .secrets.baseline has been updated as needed
  • npm run update-utilities has been run if any files in packages/utilities/src have been updated

Checklist for adding a new validation rule:

  • Added new validation rule definition (packages/ruleset/src/rules/*.js, index.js)
  • If necessary, added new validation rule implementation (packages/ruleset/src/functions/*.js, updated index.js)
  • Added new rule to default configuration (packages/ruleset/src/ibm-oas.js)
  • Added tests for new rule (packages/ruleset/test/*.test.js)
  • Added docs for new rule (docs/ibm-cloud-rules.md)
  • Added scoring rubric entry for new rule (packages/validator/src/scoring-tool/rubric.js)

Signed-off-by: Lídia Tarcza <100163235+diatrcz@users.noreply.github.com>
@diatrcz
diatrcz requested a review from pyrooka August 14, 2025 10:38
Signed-off-by: Lídia Tarcza <100163235+diatrcz@users.noreply.github.com>

@pyrooka pyrooka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we discussed on Slack.


const verbs = [];

// Verbs where pluralization can happen in the operationId based on the path

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Verbs where pluralization can happen in the operationId based on the path
// Verbs where pluralization can happen in the operationId based on the path.

Comment on lines +199 to +201
// If we have an acceptable verb, then make sure
// that the operationId starts with that verb
// and that the rest of the operation id matches the path according to the naming conventions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// If we have an acceptable verb, then make sure
// that the operationId starts with that verb
// and that the rest of the operation id matches the path according to the naming conventions
// If we have an acceptable verb, then make sure
// that the operationId starts with that verb
// and that the rest of the operation id matches
// the path according to the naming conventions.

const convertedPath = fullPath
.replace(/^\/+/, '')
.split('/')
.filter(part => !/^\{.*\}$/.test(part));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.filter(part => !/^\{.*\}$/.test(part));
.filter(part => !part.startsWith('{') && !part.endsWith('}'));

.split('/')
.filter(part => !/^\{.*\}$/.test(part));

//singularize the words in the path according to the naming conventions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//singularize the words in the path according to the naming conventions
// Singularize the words in the path according to the naming conventions.

for (let i = 0; i < verbs.length; i++) {
const correctId = verbs[i] + '_' + convertedPath.join('_');
if (correctId === operationId)
return { checkPassed: true, correctId, operationId };

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return { checkPassed: true, correctId, operationId };
return { checkPassed: true };

… naming check

Signed-off-by: Lídia Tarcza <100163235+diatrcz@users.noreply.github.com>
@diatrcz
diatrcz requested a review from pyrooka August 26, 2025 14:53
Signed-off-by: Lídia Tarcza <100163235+diatrcz@users.noreply.github.com>

@pyrooka pyrooka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!
I think we should use a feat type commit for this PR when merging it, since it adds new functionality to a rule, not just fixes an issue. Just my thought, up to you! :)

@diatrcz diatrcz changed the title fix(ibm-operationid-naming-convention): extend operationid naming check feat(ibm-operationid-naming-convention): extend operationid naming check Aug 27, 2025
@diatrcz
diatrcz merged commit 72bf9f2 into main Aug 27, 2025
7 checks passed
@diatrcz
diatrcz deleted the lt/operation-id-naming branch August 27, 2025 10:00
ibm-devx-sdk pushed a commit that referenced this pull request Aug 27, 2025
# @ibm-cloud/openapi-ruleset [1.32.0](https://github.com/IBM/openapi-validator/compare/@ibm-cloud/openapi-ruleset@1.31.2...@ibm-cloud/openapi-ruleset@1.32.0) (2025-08-27)

### Features

* **ibm-operationid-naming-convention:** extend operationid naming check ([#757](#757)) ([72bf9f2](72bf9f2))
@ibm-devx-sdk

Copy link
Copy Markdown

🎉 This PR is included in version 1.32.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

ibm-devx-sdk pushed a commit that referenced this pull request Aug 27, 2025
# ibm-openapi-validator [1.36.0](https://github.com/IBM/openapi-validator/compare/ibm-openapi-validator@1.35.3...ibm-openapi-validator@1.36.0) (2025-08-27)

### Features

* **ibm-operationid-naming-convention:** extend operationid naming check ([#757](#757)) ([72bf9f2](72bf9f2))

### Dependencies

* **@ibm-cloud/openapi-ruleset:** upgraded to 1.32.0
@ibm-devx-sdk

Copy link
Copy Markdown

🎉 This PR is included in version 1.36.0 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

@ibm-devx-sdk

Copy link
Copy Markdown

🎉 This PR is included in version 1.9.1 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants