[ 
https://issues.apache.org/jira/browse/CAMEL-24825?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18118274#comment-18118274
 ] 

Claus Ibsen commented on CAMEL-24825:
-------------------------------------

Hunted down the change asked for in this ticket. Item 1 is already done *and 
released* - it was fixed before this ticket was filed.

*The fix*

commit 3c8343102df9 - "Fix contract-first REST DSL 404 when OpenAPI base path 
is root" (Thomas Raddatz, 2026-08-27, PR 
https://github.com/apache/camel/pull/25752)

It lives in camel-platform-http-vertx, not camel-rest-openapi, which is why a 
diff of camel-4.22.0..main over components/camel-rest-openapi/src/main/java/ 
shows nothing relevant.

Root cause: RestOpenApiHelper.determineBasePath() falls back to "/" when 
servers[0].url has no path segment, so VertxPlatformHttpConsumer concatenated 
r.getBasePath() + r.getBaseUrl() as "/" + "/hello" = "//hello". Vert.x 
normalizes the doubled slash away when matching incoming requests, so every 
contract-first route registered that way was permanently unreachable and 
answered 404. The fix adds buildNormalizedEndpoint(), which strips a trailing 
slash from the base path before concatenation, applied at both the 
operation-route and api-specification call sites. 14 lines of production code 
plus two regression tests.

*Backport status: done, shipped*

commit a5b595083049 - backported to camel-4.22.x the same day, 2026-08-27, via 
PR https://github.com/apache/camel/pull/25792. It is an ancestor of the 
camel-4.22.1 tag (2026-09-13), so the fix is released in *4.22.1*.

This ticket was filed 2026-09-18 and tested against 4.22.0, which is five days 
after 4.22.1 was tagged - hence the "works on main, fails on 4.22.0" 
observation. Upgrading to 4.22.1 resolves the reported 404.

*What is left*

Only the second item: a contract with no servers entry at all fails to start 
with "URI is not absolute". That string does not appear anywhere in Camel's own 
source, so it is the JDK's java.net.URI message surfacing from a dependency 
(swagger-parser being the likely origin). The work is to catch and wrap it at 
the specification-load boundary with a message that names the missing servers 
entry, or to default the base path to "/" there. Narrowing this ticket to that 
item.

Related: PR https://github.com/apache/camel/pull/26755 attempted to fix the 404 
by making determineBasePath return "" instead of "/" for a pathless servers 
URL. That is a symptom-level change to an already-fixed bug, and it also alters 
the producer-side rest: URI and the two camel-openapi-validator callers of the 
helper. See the review on that PR.

_Claude Code on behalf of davsclaus_

> REST DSL from an OpenAPI contract whose servers URL has no path registers the 
> operations but matches none of them on 4.22.0
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24825
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24825
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-rest-openapi
>            Reporter: Claus Ibsen
>            Priority: Major
>
> With a contract whose servers entry is {"url": "http://localhost:8080"} (no 
> path), Camel 4.22.0 logs the operations in the HTTP endpoints summary 
> (/stock, /stock/{sku}, ...) but every request to them answers 404 with the 
> platform-http "Resource not found" page. With {"url": 
> "http://localhost:8080/api"} the same contract works. The 4.23.0-SNAPSHOT of 
> 2026-09-18 serves the path-less form correctly.
> Found while writing the openapi-server example for CAMEL-24808 (the example 
> now uses /api, see camel-jbang-examples issue 86). Without a servers entry at 
> all, 4.22.0 fails to start with "URI is not absolute".
> Two things to do: find the change between 4.22.0 and main that fixed the 
> path-less form and backport it to 4.22.x if it is small; and make a missing 
> servers entry a clear error (or default to "/") instead of "URI is not 
> absolute".



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to