davsclaus opened a new pull request, #28291:
URL: https://github.com/apache/camel/pull/28291
Stacked on #28282. This group of the catalog body types (CAMEL-24961) takes
the templating, the JSON and XML transform, and the validator components, and
the mvel and xquery languages.
**What the catalog says now**
| Component | Producer input | Producer output |
|---|---|---|
| velocity, freemarker, mustache, string-template, chunk, jte, thymeleaf,
mvel | `any`: the template gets the body as it is (text, or a Map, a List or a
POJO to read from) | the text the template writes (`text`); the headers are
kept |
| jolt | parsed JSON (`map`, `list`); JSON as `text`, `bytes`, `stream` or
`file` with inputType=JsonString | parsed JSON; JSON text with
outputType=JsonString |
| jslt | JSON as `text`, `bytes`, `stream` or `file` | JSON text |
| jsonata | JSON data (`map`, `list`, or a JsonNode as `pojo`); JSON text
etc. with inputType=JsonString | a JsonNode (`pojo`); JSON text with
outputType=JsonString |
| xj | XML (XML2JSON) or JSON (JSON2XML), as text, bytes, a stream or a file
| the result as text, or as xslt's output option says |
| xquery | XML: `text`, `bytes`, `stream`, `file` or a DOM | a DOM Document,
or as resultsFormat says |
| json-validator | JSON as `text`, `bytes`, `stream` or `file` | `unchanged`
|
| schematron | XML: `text`, `bytes`, `stream`, `file` or a DOM |
`unchanged`; the result is in headers |
| bean-validator | a `pojo` with constraints, or a `list` of them |
`unchanged` |
| Language | Reads | Gives |
|---|---|---|
| mvel | `any`, in request.body | `unknown`: what the expression returns |
| xquery | XML: `text`, `bytes`, `stream`, `file` or a DOM | a DOM Document,
unless resultType is set |
The xquery consumer runs the query on a message without a body on each poll,
so it fails every time; it has no body type, and I filed it as a bug.
**Checked at runtime.** Routes run with `camel run` logged the class of the
body after each step:
- **All eight template components:** each gives a String.
- velocity prints a Map body as its toString(), and `${body}` as written
when there is no body.
- **jolt:**
- JSON text with the default options gives null;
- with `inputType=JsonString` it is parsed;
- a Map gives a Map.
- **jsonata:**
- JSON text with the default options gives an empty object;
- a Map gives a JsonNode, and `outputType=JsonString` gives text.
- **jslt:** text gives text, and a Map fails.
- **xj:** both directions give text.
- **xquery:**
- a query that gives text fails with the default DOM;
- `resultsFormat=String` gives the text.
- **json-validator:** text and bytes pass unchanged, and a Map fails.
- **schematron:** keeps the body and sets the status and report headers.
- **bean-validator:** a valid POJO passes, an invalid one fails, and a
String passes unchecked.
- **The languages:** mvel and xquery in setBody.
**Docs fixed:**
- **jolt and jsonata:** the examples sent JMS text messages to the default
options, which do not parse text. They now set `inputType` and `outputType` to
`JsonString`, and say why.
- **The template components:** each page now says which context entries need
`allowContextMapAll=true`, and that the template headers need
`allowTemplateFromHeader=true`.
- **Smaller fixes:**
- json-validator validates JSON, not beans;
- xquery's result type attribute is `resultType`;
- the freemarker examples used a wrong header name;
- string-template sets `CamelStringTemplateResourceUri`;
- thymeleaf reads its context map from `CamelThymeleafVariableMap`.
**Measured.**
- I ran the validator over the 1204 human-written and 1209 model-written
route files, and the reports are the same as with #28282.
- The share of the endpoint uses in the human-written routes whose component
has body types goes from 93.0% to 93.9%.
**Tests**
- `TextBodyFlowTest.testTheBodyOfTransformations`:
- parsed data sent to jslt and json-validator is reported;
- a field read after a template is reported;
- the parsed JSON that jolt gives is reported before a file producer.
- These pass:
- the 286 tests of camel-yaml-dsl-validator;
- the 265 validator and catalog doc tests of camel-jbang-core;
- the build of camel-yaml-dsl-deserializers, which reads the catalog.
- The answers of camel_catalog_doc stay under 18 000 characters: xquery, the
largest of this group, is 9 933.
_Claude Code on behalf of davsclaus_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
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]