This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new bb1a551d72b3 CAMEL-23115 Keep base.path it present. Otherwise use
context path.
bb1a551d72b3 is described below
commit bb1a551d72b306e2394e6065831c789cc99879bd
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Mar 3 11:55:58 2026 +0100
CAMEL-23115 Keep base.path it present. Otherwise use context path.
---
....java => RestApiOverrideBasePathJettyTest.java} | 18 ++++++-----
.../jetty/rest/RestApiOverrideHostJettyTest.java | 8 ++---
.../ROOT/pages/camel-4x-upgrade-guide-4_19.adoc | 36 ++++++++++++++++++++++
3 files changed, 51 insertions(+), 11 deletions(-)
diff --git
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideBasePathJettyTest.java
similarity index 80%
copy from
components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java
copy to
components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideBasePathJettyTest.java
index 773f1b45d5b7..9c76d7456d10 100644
---
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java
+++
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideBasePathJettyTest.java
@@ -19,14 +19,14 @@ package org.apache.camel.component.jetty.rest;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jetty.BaseJettyTest;
import org.apache.camel.model.rest.RestParamType;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@Disabled("Does not run well on CI due test uses JMX mbeans")
-public class RestApiOverrideHostJettyTest extends BaseJettyTest {
+@DisabledIfSystemProperty(named = "ci.env.name", matches = ".*",
disabledReason = "Flaky on Github CI due to use of JMX")
+public class RestApiOverrideBasePathJettyTest extends BaseJettyTest {
@Override
protected boolean useJmx() {
@@ -35,12 +35,13 @@ public class RestApiOverrideHostJettyTest extends
BaseJettyTest {
@Test
public void testApi() {
- String out =
template.requestBody("jetty:http://localhost:{{port}}/api-doc", null,
String.class);
+ String out =
template.requestBody("http://localhost:{{port}}/myapp/api-doc", null,
String.class);
assertNotNull(out);
+ System.out.println(out);
assertTrue(out.contains("\"version\" : \"1.2.3\""));
assertTrue(out.contains("\"title\" : \"The hello rest thing\""));
- assertTrue(out.contains("\"host\" : \"mycoolserver/myapi\""));
+ assertTrue(out.contains("\"url\" : \"http://localhost:" + getPort() +
"/cheese\""));
assertTrue(out.contains("\"/hello/bye/{name}\""));
assertTrue(out.contains("\"/hello/hi/{name}\""));
assertTrue(out.contains("\"summary\" : \"To update the greeting
message\""));
@@ -51,8 +52,11 @@ public class RestApiOverrideHostJettyTest extends
BaseJettyTest {
return new RouteBuilder() {
@Override
public void configure() {
-
restConfiguration().component("jetty").host("localhost").port(getPort()).apiContextPath("/api-doc")
- .apiHost("mycoolserver/myapi").apiProperty("cors",
"true")
+
restConfiguration().component("jetty").host("localhost").port(getPort())
+ .contextPath("myapp")
+ .apiContextPath("/api-doc")
+ .apiProperty("base.path", "cheese")
+ .apiProperty("cors", "true")
.apiProperty("api.title", "The hello rest
thing").apiProperty("api.version", "1.2.3");
rest("/hello").consumes("application/json").produces("application/json").get("/hi/{name}")
diff --git
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java
index 773f1b45d5b7..685ed6c2b32e 100644
---
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java
+++
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestApiOverrideHostJettyTest.java
@@ -19,13 +19,13 @@ package org.apache.camel.component.jetty.rest;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.jetty.BaseJettyTest;
import org.apache.camel.model.rest.RestParamType;
-import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
-@Disabled("Does not run well on CI due test uses JMX mbeans")
+@DisabledIfSystemProperty(named = "ci.env.name", matches = ".*",
disabledReason = "Flaky on Github CI due to use of JMX")
public class RestApiOverrideHostJettyTest extends BaseJettyTest {
@Override
@@ -35,12 +35,12 @@ public class RestApiOverrideHostJettyTest extends
BaseJettyTest {
@Test
public void testApi() {
- String out =
template.requestBody("jetty:http://localhost:{{port}}/api-doc", null,
String.class);
+ String out = template.requestBody("http://localhost:{{port}}/api-doc",
null, String.class);
assertNotNull(out);
assertTrue(out.contains("\"version\" : \"1.2.3\""));
assertTrue(out.contains("\"title\" : \"The hello rest thing\""));
- assertTrue(out.contains("\"host\" : \"mycoolserver/myapi\""));
+ assertTrue(out.contains("\"url\" : \"http://mycoolserver/myapi\""));
assertTrue(out.contains("\"/hello/bye/{name}\""));
assertTrue(out.contains("\"/hello/hi/{name}\""));
assertTrue(out.contains("\"summary\" : \"To update the greeting
message\""));
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc
index a6a9eeca11bf..49b23bc9d53f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_19.adoc
@@ -271,6 +271,42 @@ The `camel-json-patch` is now deprecated - the library it
uses is not active mai
When configured a custom `IdempotentRepository` on `camel-mail` endpoint, then
Camel will now auto-start
the bean which is similar to what `camel-file` do as well.
+=== camel-openapi-java
+
+When using _code first_ Rest DSL and have configured `base.path` then this
will now be exclusively used
+for the returned server url in the API specification.
+
+For example here we set `base.path=cheese`:
+
+[source,java]
+----
+restConfiguration().component("jetty").host("localhost").port(getPort())
+ .contextPath("myapp")
+ .apiContextPath("/api-doc")
+ .apiProperty("cors", "true").apiProperty("base.path", "cheese")
+ .apiProperty("api.title", "The hello rest
thing").apiProperty("api.version", "1.2.3");
+----
+
+Then the generated API specification now returns:
+
+[source,json]
+----
+ "servers" : [ {
+ "url" : "http://localhost:58678/cheese"
+ } ],
+----
+
+Previously the context-path would always be used:
+
+[source,json]
+----
+ "servers" : [ {
+ "url" : "http://localhost:58678/myapp"
+ } ],
+----
+
+The intention is to allow to configure the `base.path` _as is_ in the return
API specification.
+
=== camel-nitrite (Removal)
The camel-nitrite is removed in this version. It was deprecated in 4.10.