gnodet opened a new pull request, #26801: URL: https://github.com/apache/camel/pull/26801
## Summary Fix REST DSL from an OpenAPI contract failing when the `servers` list is missing or contains a URL with no path component. ## Root Cause `RestOpenApiHelper.getBasePathFromOpenApi()` returns: - `null` when `servers` is `null` or empty (no servers entry at all) - `""` (empty string) when a server URL has no path component (e.g. `http://localhost:8080`) Both `RestOpenApiHelper.determineBasePath()` and `RestOpenApiEndpoint.determineBasePath()` used `isNotEmpty(specificationBasePath)` to check the return value. Since `isNotEmpty("")` is `false`, a pathless server URL (returning `""`) was incorrectly treated as "not present", causing both methods to fall through to `DEFAULT_BASE_PATH` (`"/"`). When the spec has **no servers entry at all**, the fallback to `"/"` then flows into `createConsumerFor` as `rest:METHOD:/:template`. The `:` in that URI pattern triggers a JDK-level `URISyntaxException: URI is not absolute` during consumer creation, preventing the route from starting. ## Fix In both `determineBasePath` methods: - Only fall back to `DEFAULT_BASE_PATH` when `openapi.getServers()` is `null` or empty (truly unspecified) - When servers are present, use a `!= null` guard instead of `isNotEmpty`, so an empty string base path (from a pathless server URL) is correctly honoured ## Tests Added (`RestOpenApiEndpointV3Test`) - `shouldDetermineEmptyBasePathFromOpenApiServer` — verifies that `http://localhost:8080` (no path) produces `""` via `getBasePathFromOpenApi`, `endpoint.determineBasePath`, and `RestOpenApiHelper.determineBasePath` - `shouldDefaultBasePathWhenNoServersInSpec` — verifies that a spec with no servers entry at all still falls back correctly to `"/"` (the `DEFAULT_BASE_PATH`) ## Related - Fixes [CAMEL-24825](https://issues.apache.org/jira/browse/CAMEL-24825) - Related closed PR: #26755 (same root cause, similar fix approach) --- _Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
