gnodet-bot commented on code in PR #28242:
URL: https://github.com/apache/camel/pull/28242#discussion_r4345740420
##########
dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ai/CatalogDocs.java:
##########
@@ -1636,11 +1634,53 @@ private static void addCommonModelFields(JsonObject
result, BaseModel<?> model)
}
if (!model.getBodyTypes().isEmpty()) {
// what the body is after the step and what it needs, which the
options do not say (CAMEL-24961)
- result.put("bodyTypes",
JsonMapper.asJsonObjectBodyTypes(model.getBodyTypes()));
+ result.put("bodyTypes", bodyTypes(model.getBodyTypes()));
result.put("bodyTypesHint", BODY_TYPES_HINT);
}
}
+ /**
+ * The body types a line per side, as compact as the options are: the
carriers, the Java type, the format, the
+ * description, the body for other option values, and the options that
make it not known (CAMEL-24961).
+ */
+ static JsonObject bodyTypes(Map<String, BodyTypeModel> bodyTypes) {
+ JsonObject answer = new JsonObject();
+ for (Map.Entry<String, BodyTypeModel> entry : bodyTypes.entrySet()) {
+ BodyTypeModel side = entry.getValue();
+ StringBuilder line = new
StringBuilder(carriers(side.getCarriers(), side.getJavaType()));
+ if (side.getFormat() != null) {
+ line.append(", as ").append(side.getFormat());
+ }
+ if (side.getDescription() != null) {
+ line.append(". ").append(side.getDescription());
+ }
+ if (!side.getByOption().isEmpty()) {
+ List<String> values = new ArrayList<>();
+ for (BodyTypeModel.OptionBodyTypeModel option :
side.getByOption()) {
+ values.add(option.getOption() + "=" + option.getValue() +
": "
+ + carriers(option.getCarriers(),
option.getJavaType()));
+ }
+ line.append(". With ").append(String.join("; ", values));
+ }
+ if (!side.getDependsOn().isEmpty()) {
+ line.append(". Not known when ").append(String.join(" or ",
side.getDependsOn())).append(" is set");
Review Comment:
π‘ **Nit β formatting inconsistency between `dependsOn` and `carriers()`**
The `dependsOn` branch joins with plain `" or "` (producing e.g. `"a or b or
c"` for 3 items), while `carriers()` uses the Oxford-ish comma style (producing
`"a, b or c"`). JMS's `consumerReply` and `producerIn` sides each have 3
`dependsOn` values (`jmsMessageType`, `messageConverter`, `transferExchange`),
so the output would read `"jmsMessageType or messageConverter or
transferExchange is set"` β arguably less readable than the comma variant.
Consider aligning both to the same style, e.g. using the same comma+or
helper:
```suggestion
line.append(". Not known when
").append(carriers(side.getDependsOn(), null)).append(" is set");
```
β¦or extract a small shared helper. Either way, consistency between the two
paths would be nice.
--
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]