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 ac19d5aac129 chore: camel-jbang - the contract-first Rest DSL ranks as
a rest-openapi sample again (main build) (#27328)
ac19d5aac129 is described below
commit ac19d5aac129783e7b624d49c98accf1fa688815
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Oct 4 08:01:49 2026 +0200
chore: camel-jbang - the contract-first Rest DSL ranks as a rest-openapi
sample again (main build) (#27328)
chore: camel-jbang - the contract-first Rest DSL ranks as a rest-openapi
sample again
CAMEL-24649 added an example of a rest-openapi consumer to the component
page.
Examples that name the scheme rank first, so the contract-first Rest DSL
(rest: openApi:, the form the page recommends) dropped out of the two
samples
a model gets by default, and CatalogSamplesTest failed on main. The Rest DSL
with openApi runs on rest-openapi, so it now counts as a use of it and keeps
its place, first on the page. Also regenerates eip-samples.json, which
CAMEL-24649 left stale (rest-dsl-openapi.adoc).
Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
---
.../camel/dsl/jbang/core/commands/ai/eip-samples.json | 6 +++++-
.../camel/dsl/jbang/core/commands/ai/CatalogSamples.java | 13 ++++++++++++-
.../dsl/jbang/core/commands/ai/CatalogSamplesTest.java | 6 ++++--
3 files changed, 21 insertions(+), 4 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/generated/resources/org/apache/camel/dsl/jbang/core/commands/ai/eip-samples.json
b/dsl/camel-jbang/camel-jbang-core/src/generated/resources/org/apache/camel/dsl/jbang/core/commands/ai/eip-samples.json
index b2ba3ff34354..b4e84fed68ba 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/generated/resources/org/apache/camel/dsl/jbang/core/commands/ai/eip-samples.json
+++
b/dsl/camel-jbang/camel-jbang-core/src/generated/resources/org/apache/camel/dsl/jbang/core/commands/ai/eip-samples.json
@@ -992,12 +992,16 @@
},
{
"source": "rest-dsl-openapi.adoc",
- "yaml": "- rest:\n openApi:\n specification: petstore-v3.json\n
missingOperation: mock\n"
+ "yaml": "- rest:\n openApi:\n specification: petstore-v3.json\n
missingOperation: ignore\n unmatchedRequestHandling: camel\n"
},
{
"source": "rest-dsl.adoc",
"yaml": "- rest:\n path: \"items\/\"\n get:\n - path:
\"{id}\/{filename}.{content-type}\"\n to: \"direct:item\"\n"
},
+ {
+ "source": "rest-dsl-openapi.adoc",
+ "yaml": "- rest:\n openApi:\n specification: petstore-v3.json\n
missingOperation: mock\n"
+ },
{
"source": "rest-dsl.adoc",
"yaml": "- restConfiguration:\n inlineRoutes: true\n- rest:\n
get:\n - path: \"\/customers\/{id}\"\n to:
\"direct:customerDetails\"\n - path: \"\/customers\/{id}\/orders\"\n
to: \"direct:customerOrders\"\n post:\n - path:
\"\/customers\/neworder\"\n to: \"direct:customerNewOrder\"\n"
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogSamples.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogSamples.java
index da2cdc36882f..a8243e499bb0 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogSamples.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogSamples.java
@@ -25,6 +25,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
@@ -376,10 +377,20 @@ public final class CatalogSamples {
}
}
+ /**
+ * Examples that use a component without naming its scheme: the
contract-first Rest DSL ({@code rest: openApi:})
+ * runs on rest-openapi and is the form its page recommends for serving an
API, so it ranks with the examples that
+ * use the endpoint instead of after them (where an example of a
rest-openapi consumer pushed it out of the first
+ * two).
+ */
+ private static final Map<String, String> ALSO_USED_BY =
Map.of("rest-openapi", "^\\s+openApi:");
+
/** Matches an endpoint uri of one of the schemes: {@code uri: kafka:...},
{@code uri: "kafka:..."}. */
private static Pattern schemePattern(Set<String> schemes) {
String any =
schemes.stream().map(Pattern::quote).collect(Collectors.joining("|"));
- return Pattern.compile("(uri:\\s*[\"']?|[\"'])(" + any + "):");
+ String also =
schemes.stream().map(ALSO_USED_BY::get).filter(Objects::nonNull).map(p -> "|" +
p)
+ .collect(Collectors.joining());
+ return Pattern.compile("(uri:\\s*[\"']?|[\"'])(" + any + "):" + also,
Pattern.MULTILINE);
}
private static ComponentModel componentModel(CamelCatalog catalog, String
name) {
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogSamplesTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogSamplesTest.java
index 2c464cf51140..fd599d90f8d1 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogSamplesTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogSamplesTest.java
@@ -249,8 +249,10 @@ public class CatalogSamplesTest {
void restOpenApiShowsTheConsumerEndpointAndTheContractFirstRest() {
CamelCatalog catalog = new DefaultCamelCatalog();
JsonObject o = CatalogSamples.sample(catalog, "component",
"rest-openapi", 2);
- assertThat(yaml(o, 0)).contains("rest-openapi:");
- assertThat(yaml(o,
1)).contains("openApi:").contains("direct:getPetById");
+ // the contract-first Rest DSL counts as a use of rest-openapi and
keeps its place, first on the page, ahead of
+ // the examples of a rest-openapi consumer (such as the one for
unmatched requests)
+ assertThat(yaml(o,
0)).contains("openApi:").contains("direct:getPetById");
+ assertThat(yaml(o, 1)).contains("rest-openapi:");
}
@Test