davsclaus commented on code in PR #27421:
URL: https://github.com/apache/camel/pull/27421#discussion_r4193999244
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogDocs.java:
##########
@@ -1535,6 +1568,15 @@ public static JsonObject optionToJson(BaseOptionModel
opt, String scope) {
enums.addAll(opt.getEnums());
o.put("enumValues", enums);
}
+ if ("element".equals(opt.getKind()) && opt.getOneOfs() != null &&
!opt.getOneOfs().isEmpty()) {
Review Comment:
Thanks, that was too broad. Applied your condition in 9e9f61168e: the hint
is only for an object-typed element whose oneOf list does not contain its own
name. `errorHandlerType` keeps it, while `outputs`, `setHeaders.headers`,
`choice.when` and `doTry.doCatch` do not get it.
`elementsThatAreNotWrittenAsTheirKindHaveNoKindHint` asserts no `oneOf`/`yaml`
on those four.
_Claude Code on behalf of davsclaus_
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogDocs.java:
##########
@@ -345,12 +345,45 @@ private static JsonObject eipDoc(
String matchedTerm) {
String doc = includeDoc ? catalog.asciiDoc(model.getName() + "-eip") :
null;
JsonObject result = eipDoc(model, filter, scope, doc);
+ if (filter != null && scope != OptionScope.NONE &&
result.getIntegerOrDefault("matchedOptions", 0) == 0) {
+ putNestedOptions(catalog, model, filter, result);
+ }
if (matchedTerm != null) {
result.put("matchedTerm", matchedTerm);
}
return result;
}
+ /**
+ * The options of the elements of an EIP that match the filter, when none
of its own do: logStackTrace is an option
+ * of the redeliveryPolicy of onException, and a filter on onException
found nothing (CAMEL-25370).
+ */
+ private static void putNestedOptions(CamelCatalog catalog, EipModel model,
String filter, JsonObject result) {
+ JsonArray nested = new JsonArray();
+ for (BaseOptionModel opt : model.getOptions()) {
+ if (!"element".equals(opt.getKind())) {
+ continue;
+ }
+ EipModel element = catalog.eipModel(opt.getName());
Review Comment:
Fixed in 9e9f61168e: the nested search follows an element only when the
option's java type (inside `List<...>`, without generics) is the model's java
type, so `templatedRoute.bean`, `responseMessage.header` and
`beanFactory.script` are skipped
(`theNestedSearchOnlyFollowsTheModelTheElementHolds`). For a list element the
hint now shows a list (`under: [{option: ...}]`).
Two parts I left for a follow-up: the YAML key can differ from the catalog
element name (`templateParameter` is written as `parameters:`), which needs the
YAML DSL schema rather than the catalog model; and `errorHandler` itself gets
no `nestedOptions`, as its options sit in the models of its kinds
(`deadLetterChannel`, ...) behind `errorHandlerType`, which needs following the
oneOf kinds. I'll file a JIRA for both.
_Claude Code on behalf of davsclaus_
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogDocs.java:
##########
@@ -345,12 +345,45 @@ private static JsonObject eipDoc(
String matchedTerm) {
String doc = includeDoc ? catalog.asciiDoc(model.getName() + "-eip") :
null;
JsonObject result = eipDoc(model, filter, scope, doc);
+ if (filter != null && scope != OptionScope.NONE &&
result.getIntegerOrDefault("matchedOptions", 0) == 0) {
Review Comment:
Right. Fixed in 9e9f61168e: the fallback only runs when the filter matched
none of the EIP's own options, including the ones the scope left out
(`omittedOptions == 0`), and `putNestedOptions` applies the scope to the nested
options too. `theNestedSearchKeepsTheScope` covers `onException
optionsFilter=redelivery includeOptions=required`.
_Claude Code on behalf of davsclaus_
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogSamples.java:
##########
@@ -90,6 +90,10 @@ public final class CatalogSamples {
Map.entry("redeliveryPolicy", "onException"),
Map.entry("deadLetterChannel", "errorHandler"),
Map.entry("defaultErrorHandler", "errorHandler"),
+ Map.entry("noErrorHandler", "errorHandler"),
+ Map.entry("jtaTransactionErrorHandler", "errorHandler"),
+ Map.entry("springTransactionErrorHandler", "errorHandler"),
+ Map.entry("refErrorHandler", "errorHandler"),
Review Comment:
Good point. Changed in 9e9f61168e: the note now checks whether a sample
writes the kind. When none does (`refErrorHandler`,
`jtaTransactionErrorHandler`, ...), it says the samples show another kind in
the same place, to write `<kind>` where they write theirs, and that
`camel_catalog_doc <kind>` gives its options.
`anErrorHandlerKindTheSamplesDoNotShow` pins it.
_Claude Code on behalf of davsclaus_
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogSamples.java:
##########
@@ -648,7 +652,17 @@ static String normalizeKind(String kind) {
return k;
}
+ /** The kinds of error handler, each the one key under errorHandler:. */
+ static final Set<String> ERROR_HANDLERS = Set.of("errorHandler",
"deadLetterChannel", "defaultErrorHandler",
+ "noErrorHandler", "jtaTransactionErrorHandler",
"springTransactionErrorHandler", "refErrorHandler");
+
static String placement(String key) {
+ if (ERROR_HANDLERS.contains(key)) {
+ // a step it is not, and it has two places (CAMEL-25370)
+ return "errorHandler: with the kind (deadLetterChannel,
defaultErrorHandler, noErrorHandler) as its one key,"
+ + " either as a top-level list item - errorHandler: for
every route, or under one route, next to from:,"
+ + " for that route only; never a step";
Review Comment:
Applied in 9e9f61168e: the placement now names a routeConfiguration as the
third place, and the test checks it.
_Claude Code on behalf of davsclaus_
--
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]