Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make schema path de-resolution utility more robust #685

Merged
merged 1 commit into from
Sep 25, 2024

Conversation

dpopp07
Copy link
Member

@dpopp07 dpopp07 commented Sep 24, 2024

Before, the check used faulty logic to determine if we were on the last iteration through a loop. This could lead to unintended behavior in rare cases. This clarifies the logic to only execute the last time through the loop and for no other reason (the potential reason being if the last path segment matched an earlier path segment).

for (const pathSegment of path.split('.')) {
const pathSegments = path.split('.');

for (let i = 0; i < pathSegments.length; i++) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The only real change is that now we use a numerically-indexed for-loop so that we know for sure when we're going through it for the last time.

Copy link
Member

@pyrooka pyrooka left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

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

Only thing I could find was that the copyright year should be updated.

Before, the check used faulty logic to determine if we were on the last
iteration through a loop. This could lead to unintended behavior in rare
cases. This clarifies the logic to only execute the last time through the
loop and for no other reason (the potential reason being if the last path
segment matched an earlier path segment).

Signed-off-by: Dustin Popp <dpopp07@gmail.com>
@dpopp07
Copy link
Member Author

dpopp07 commented Sep 25, 2024

Only thing I could find was that the copyright year should be updated.

Good catch! Fixed

@dpopp07 dpopp07 merged commit b25b840 into main Sep 25, 2024
4 checks passed
@dpopp07 dpopp07 deleted the dp/fix-schemanameatpath branch September 25, 2024 15:17
ibm-devx-sdk pushed a commit that referenced this pull request Sep 25, 2024
## @ibm-cloud/openapi-ruleset [1.23.1](https://github.com/IBM/openapi-validator/compare/@ibm-cloud/openapi-ruleset@1.23.0...@ibm-cloud/openapi-ruleset@1.23.1) (2024-09-25)

### Bug Fixes

* make schema path de-resolution utility more robust ([#685](#685)) ([b25b840](b25b840))
@ibm-devx-sdk
Copy link

🎉 This PR is included in version 1.23.1 🎉

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

Your semantic-release bot 📦🚀

@ibm-devx-sdk
Copy link

🎉 This PR is included in version 1.24.1 🎉

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

Your semantic-release bot 📦🚀

@ibm-devx-sdk
Copy link

🎉 This PR is included in version 1.5.0 🎉

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.

4 participants