Fix common base path detection to match only complete path segments#1878
Merged
TharmiganK merged 7 commits intomasterfrom Jan 30, 2026
Merged
Fix common base path detection to match only complete path segments#1878TharmiganK merged 7 commits intomasterfrom
TharmiganK merged 7 commits intomasterfrom
Conversation
lnash94
reviewed
Jan 28, 2026
openapi-cli/src/test/resources/generators/sanitizer/basepath_version_mismatch.yaml
Show resolved
Hide resolved
f226383 to
7bb783b
Compare
…culation in OASModifier
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts common base path detection in OASModifier so it only matches complete path segments (avoiding false positives like /v2 matching /v2.1), and adds regression tests/resources for version/parameter edge cases.
Changes:
- Add path-segment-aware prefix checking when computing common base paths.
- Improve handling of parameterized path segments when determining the non-parameterized prefix.
- Add new sanitizer test cases and expected outputs covering version mismatches and embedded path parameters.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| openapi-core/src/main/java/io/ballerina/openapi/core/generators/common/OASModifier.java | Updates common base path detection to respect path segment boundaries; adjusts parameterized-path handling. |
| openapi-cli/src/test/java/io/ballerina/openapi/generators/common/OASModifierTests.java | Adds regression tests for version mismatch and parameterized segment scenarios. |
| openapi-cli/src/test/resources/generators/sanitizer/basepath_version_mismatch.yaml | New input spec for version-segment mismatch scenario. |
| openapi-cli/src/test/resources/generators/sanitizer/basepath_with_parameter_1.yaml | New input spec where version-like segment contains an embedded parameter. |
| openapi-cli/src/test/resources/generators/sanitizer/basepath_with_parameter_2.yaml | New input spec where an earlier common base path exists despite embedded parameter later. |
| openapi-cli/src/test/resources/generators/sanitizer/basepath_with_parameter_3.yaml | New input spec covering parameterized segment cases with no common base path. |
| openapi-cli/src/test/resources/generators/sanitizer/expected/modified_basepath_with_parameter_2.yaml | Expected output for the “common base path exists” parameter case. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
openapi-core/src/main/java/io/ballerina/openapi/core/generators/common/OASModifier.java
Outdated
Show resolved
Hide resolved
openapi-core/src/main/java/io/ballerina/openapi/core/generators/common/OASModifier.java
Show resolved
Hide resolved
openapi-core/src/main/java/io/ballerina/openapi/core/generators/common/OASModifier.java
Show resolved
Hide resolved
|
lnash94
approved these changes
Jan 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Purpose
Fixes: ballerina-platform/ballerina-library#8574