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-jbang-examples.git
The following commit(s) were added to refs/heads/main by this push:
new e49c0df chore: rest-code-first - the API description names
http://localhost:8080 as its server (#136)
e49c0df is described below
commit e49c0dfa4964f0c695d07ade726d66f929cad653
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 11 09:16:25 2026 +0100
chore: rest-code-first - the API description names http://localhost:8080 as
its server (#136)
Without host and port in the REST configuration the generated OpenAPI
description said "servers": [{"url": "http://0.0.0.0"}], which no client
generated from it can call. The Citrus test checks the server too.
Signed-off-by: Claus Ibsen <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
contracts/rest-code-first/README.md | 3 ++-
contracts/rest-code-first/rest-code-first.camel.yaml | 2 ++
contracts/rest-code-first/test/rest-code-first.citrus.it.yaml | 2 ++
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/contracts/rest-code-first/README.md
b/contracts/rest-code-first/README.md
index fe96d6c..7044d13 100644
--- a/contracts/rest-code-first/README.md
+++ b/contracts/rest-code-first/README.md
@@ -50,7 +50,8 @@ Stop the example with `ctrl` + `c`.
JSON text.
- `apiContextPath: openapi` serves the API description that Camel generates
from the operations.
`application.properties` adds `camel-openapi-java` for it, which `camel run`
does not add by itself for a
- code-first API.
+ code-first API. `host` and `port` of the REST configuration are the server
the description names, so a client
+ generated from it calls `http://localhost:8080` (without them it says
`http://0.0.0.0`).
- `orders.json` holds the three orders of the shop.
## Build it step by step
diff --git a/contracts/rest-code-first/rest-code-first.camel.yaml
b/contracts/rest-code-first/rest-code-first.camel.yaml
index b5f0daa..e0379d4 100644
--- a/contracts/rest-code-first/rest-code-first.camel.yaml
+++ b/contracts/rest-code-first/rest-code-first.camel.yaml
@@ -3,6 +3,8 @@
- restConfiguration:
bindingMode: json
apiContextPath: openapi
+ host: localhost
+ port: "{{camel.server.port}}"
- rest:
path: /orders
diff --git a/contracts/rest-code-first/test/rest-code-first.citrus.it.yaml
b/contracts/rest-code-first/test/rest-code-first.citrus.it.yaml
index db0be1e..1bce177 100644
--- a/contracts/rest-code-first/test/rest-code-first.citrus.it.yaml
+++ b/contracts/rest-code-first/test/rest-code-first.citrus.it.yaml
@@ -93,3 +93,5 @@ actions:
- jsonPath:
- expression: "$.paths['/orders/{id}'].get.operationId"
value: "getOrder"
+ - expression: "$.servers[0].url"
+ value: "http://localhost:8080"