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-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new e65235d6b chore: default data types on the data format, crypto, Kafka
routing and geo actions (#3117) (#3299)
e65235d6b is described below
commit e65235d6b2fad2561e12f34bcc7c57bba1dbf171
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Nov 20 21:13:23 2026 +0100
chore: default data types on the data format, crypto, Kafka routing and geo
actions (#3117) (#3299)
- in: binary on json-deserialize-action, jslt-action, crypto-encrypt-action
and crypto-decrypt-action; jslt-action now also takes a Jackson JsonNode,
and crypto-decrypt-action sets Content-Type application/octet-stream.
- in: json on message-timestamp-router-action and value-to-key-action;
Content-Type application/json is no longer needed.
- in: text on nominatim-geocode-action and ogcapi-features-action.
The planned out: struct on json-/avro-/protobuf-deserialize-action and
jsonata-action is left out: Camel's DefaultTransformerRegistry resolves the
from-type transformer (application-x-struct) before it lazy-loads the
to-type
one, so a following Kamelet's input default is skipped (verified with
json-deserialize-action -> value-to-key-action).
Citrus: the crypto test checks the body class and Content-Type after
decrypting, a new jslt test feeds a JsonNode, and the value-to-key test
no longer sets Content-Type.
Claude-Session: https://claude.ai/code/session_016Y4dDmBDsSWV117kccuNf9
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
kamelets/crypto-decrypt-action.kamelet.yaml | 12 +++++--
kamelets/crypto-encrypt-action.kamelet.yaml | 7 ++++
kamelets/jslt-action.kamelet.yaml | 11 +++++--
kamelets/json-deserialize-action.kamelet.yaml | 8 +++++
.../message-timestamp-router-action.kamelet.yaml | 12 ++++---
kamelets/nominatim-geocode-action.kamelet.yaml | 7 ++++
kamelets/ogcapi-features-action.kamelet.yaml | 8 +++++
kamelets/value-to-key-action.kamelet.yaml | 13 ++++----
.../main/resources/META-INF/kamelets-index.json | 8 ++---
.../kamelets/crypto-decrypt-action.kamelet.yaml | 12 +++++--
.../kamelets/crypto-encrypt-action.kamelet.yaml | 7 ++++
.../resources/kamelets/jslt-action.kamelet.yaml | 11 +++++--
.../kamelets/json-deserialize-action.kamelet.yaml | 8 +++++
.../message-timestamp-router-action.kamelet.yaml | 12 ++++---
.../kamelets/nominatim-geocode-action.kamelet.yaml | 7 ++++
.../kamelets/ogcapi-features-action.kamelet.yaml | 8 +++++
.../kamelets/value-to-key-action.kamelet.yaml | 13 ++++----
.../crypto/crypto-action-route.citrus.it.yaml | 5 +++
.../test/resources/crypto/crypto-action-route.yaml | 9 ++++-
.../kafkarouter/value-to-key-action-route.yaml | 3 --
.../jslt-action-jsonnode-route.citrus.it.yaml} | 38 +++++++---------------
.../jslt-action-jsonnode-route.yaml} | 19 ++++++-----
22 files changed, 164 insertions(+), 74 deletions(-)
diff --git a/kamelets/crypto-decrypt-action.kamelet.yaml
b/kamelets/crypto-decrypt-action.kamelet.yaml
index 04e039881..5faf4dd15 100644
--- a/kamelets/crypto-decrypt-action.kamelet.yaml
+++ b/kamelets/crypto-decrypt-action.kamelet.yaml
@@ -38,9 +38,9 @@ spec:
Input: the encrypted data exactly as `crypto-encrypt-action` produced
it, as bytes or a stream. If it was encoded on the way, for example in Base64,
decode it first.
- Output: the body is the original data, as bytes (a stream). The headers
are kept.
+ Output: the body is the original data, as bytes (a stream), and the
`Content-Type` header is `application/octet-stream`. The other headers are kept.
- Good to know: the `Content-Type` header is kept as it comes, which after
`crypto-encrypt-action` is `application/octet-stream`: set it again to the type
of the original data when the next step needs it, for example with
`insert-header-action`. Data that was changed, or a different `algorithm`,
`mode` or `key` than when encrypting, fails the message with "Message
authentication failed". The key is a secret; keep it in a vault or a secret,
not in plain configuration.
+ Good to know: set the `Content-Type` header again to the type of the
original data when the next step needs it, for example with
`insert-header-action`. Data that was changed, or a different `algorithm`,
`mode` or `key` than when encrypting, fails the message with "Message
authentication failed". The key is a secret; keep it in a vault or a secret,
not in plain configuration.
required:
- algorithm
- key
@@ -63,6 +63,14 @@ spec:
format: password
x-descriptors:
- urn:camel:group:credentials
+ dataTypes:
+ in:
+ default: binary
+ types:
+ binary:
+ format: "application-octet-stream"
+ description: "The encrypted data, as bytes or a stream."
+ mediaType: application/octet-stream
dependencies:
- "camel:kamelet"
- "camel:crypto"
diff --git a/kamelets/crypto-encrypt-action.kamelet.yaml
b/kamelets/crypto-encrypt-action.kamelet.yaml
index 9ba413728..e01d59f1c 100644
--- a/kamelets/crypto-encrypt-action.kamelet.yaml
+++ b/kamelets/crypto-encrypt-action.kamelet.yaml
@@ -64,6 +64,13 @@ spec:
x-descriptors:
- urn:camel:group:credentials
dataTypes:
+ in:
+ default: binary
+ types:
+ binary:
+ format: "application-octet-stream"
+ description: "The data to encrypt, as bytes or a stream."
+ mediaType: application/octet-stream
out:
default: binary
types:
diff --git a/kamelets/jslt-action.kamelet.yaml
b/kamelets/jslt-action.kamelet.yaml
index 375f3854e..1601b9d4a 100644
--- a/kamelets/jslt-action.kamelet.yaml
+++ b/kamelets/jslt-action.kamelet.yaml
@@ -36,11 +36,11 @@ spec:
Use it to map the JSON of one system to the JSON another system expects,
for example to keep only some fields, rename them or count the items of an
order. To build text rather than JSON, use `mustache-template-action`;
`jolt-transformation-action` reshapes JSON with Jolt specifications instead.
- Input: JSON text, bytes or a stream. The transformation sees the body as
`.` and a header as `$headers.name`, for example `{"customer": .name, "items":
size(.items), "source": $headers.origin}`.
+ Input: JSON text, as text, bytes or a stream, or parsed JSON as a
Jackson `JsonNode`, such as the output of `json-deserialize-action`. The
transformation sees the body as `.` and a header as `$headers.name`, for
example `{"customer": .name, "items": size(.items), "source": $headers.origin}`.
Output: the body is the result as JSON text in bytes, and the
`Content-Type` header is set to `application/json`. The other headers are kept.
- Good to know: parsed JSON (a Map or a JsonNode, such as the output of
`json-deserialize-action`) fails the message: give the JSON as text. A field
whose value is missing, such as a header that is not set, is left out of the
result. The transformation is loaded from a file, the classpath or a URL given
by the `template` option; it cannot come from the message. Headers that start
with `CamelJslt` are removed from the message first, so they cannot change what
the Kamelet does.
+ Good to know: a Map fails the message: give the JSON as text. A field
whose value is missing, such as a header that is not set, is left out of the
result. The transformation is loaded from a file, the classpath or a URL given
by the `template` option; it cannot come from the message. Headers that start
with `CamelJslt` are removed from the message first, so they cannot change what
the Kamelet does.
required:
- template
type: object
@@ -52,6 +52,13 @@ spec:
example: "file:///opt/templates/order.jslt"
pattern: "^(http|https|file|classpath|ref|bean)://.*"
dataTypes:
+ in:
+ default: binary
+ types:
+ binary:
+ format: "application-octet-stream"
+ description: "The JSON text, as bytes or a stream."
+ mediaType: application/octet-stream
out:
default: json
types:
diff --git a/kamelets/json-deserialize-action.kamelet.yaml
b/kamelets/json-deserialize-action.kamelet.yaml
index 8e83c9ef4..3c6ba16fd 100644
--- a/kamelets/json-deserialize-action.kamelet.yaml
+++ b/kamelets/json-deserialize-action.kamelet.yaml
@@ -42,6 +42,14 @@ spec:
Good to know: a body that is not valid JSON fails the message.
type: object
+ dataTypes:
+ in:
+ default: binary
+ types:
+ binary:
+ format: "application-octet-stream"
+ description: "The JSON text, as bytes or a stream."
+ mediaType: application/octet-stream
dependencies:
- "camel:kamelet"
- "camel:jackson3"
diff --git a/kamelets/message-timestamp-router-action.kamelet.yaml
b/kamelets/message-timestamp-router-action.kamelet.yaml
index d96c3371f..602c9a37e 100644
--- a/kamelets/message-timestamp-router-action.kamelet.yaml
+++ b/kamelets/message-timestamp-router-action.kamelet.yaml
@@ -36,7 +36,7 @@ spec:
Use it to spread the records over one topic per day or per month by a
date in the data, such as the date of an order, in a flow from `kafka-source`
to `kafka-sink`. To use the time the record was written to Kafka instead use
`timestamp-router-action`.
- Input: a JSON object as JSON text, with the `Content-Type` header set to
`application/json`. The name of the topic is read from the `CamelKafkaTopic`
header, which `kafka-source` sets.
+ Input: a JSON object, as JSON text, as bytes, as a Map or as parsed JSON
(a Jackson `JsonNode`). The `Content-Type` header is not needed. The name of
the topic is read from the `CamelKafkaTopic` header, which `kafka-source` sets.
Output: the same JSON object, as JSON text in bytes, with `Content-Type`
set to `application/json`. When one of the `timestampKeys` fields is found, the
`CamelKafkaOverrideTopic` header is set to the new name, and `kafka-sink`
writes the record to that topic instead of its own `topic`.
@@ -70,15 +70,17 @@ spec:
type: object
dataTypes:
in:
+ default: json
+ types:
+ json:
+ format: "application-json"
+ description: "The JSON object, as JSON text in bytes."
+ mediaType: application/json
headers:
CamelKafkaTopic:
title: Kafka Topic
description: "The topic the record was read from, as `kafka-source`
sets it."
type: string
- Content-Type:
- title: Content Type
- description: "Must be `application/json`."
- type: string
out:
default: json
types:
diff --git a/kamelets/nominatim-geocode-action.kamelet.yaml
b/kamelets/nominatim-geocode-action.kamelet.yaml
index 1223070ab..fbbd5e7b9 100644
--- a/kamelets/nominatim-geocode-action.kamelet.yaml
+++ b/kamelets/nominatim-geocode-action.kamelet.yaml
@@ -51,6 +51,13 @@ spec:
example: "https://nominatim.openstreetmap.org"
type: string
dataTypes:
+ in:
+ default: text
+ types:
+ text:
+ format: "text-plain"
+ description: "The place name or address to look up."
+ mediaType: text/plain
out:
default: json
headers:
diff --git a/kamelets/ogcapi-features-action.kamelet.yaml
b/kamelets/ogcapi-features-action.kamelet.yaml
index f63c0df75..97018547b 100644
--- a/kamelets/ogcapi-features-action.kamelet.yaml
+++ b/kamelets/ogcapi-features-action.kamelet.yaml
@@ -147,6 +147,14 @@ spec:
example: orders.write
x-descriptors:
- urn:camel:group:credentials
+ dataTypes:
+ in:
+ default: text
+ types:
+ text:
+ format: "text-plain"
+ description: "More query parameters, such as `name=Lake Baikal`, or
an empty body."
+ mediaType: text/plain
types:
in:
mediaType: text/plain
diff --git a/kamelets/value-to-key-action.kamelet.yaml
b/kamelets/value-to-key-action.kamelet.yaml
index 0f83428d2..604971b8c 100644
--- a/kamelets/value-to-key-action.kamelet.yaml
+++ b/kamelets/value-to-key-action.kamelet.yaml
@@ -36,7 +36,7 @@ spec:
Use it to take the key of the record from the data, before `kafka-sink`,
for example the customer of an order, so that all the records of one customer
go to the same partition and stay in order. To take the key from a header
instead use `set-kafka-key-action`.
- Input: a JSON object as JSON text, with the `Content-Type` header set to
`application/json`.
+ Input: a JSON object, as JSON text, as bytes, as a Map or as parsed JSON
(a Jackson `JsonNode`). The `Content-Type` header is not needed.
Output: the same JSON object, as JSON text in bytes, with `Content-Type`
set to `application/json`. The `CamelKafkaKey` header, which `kafka-sink` uses
as the key of the record, is set to a Map of the fields named in `fields` and
their values.
@@ -52,11 +52,12 @@ spec:
type: object
dataTypes:
in:
- headers:
- Content-Type:
- title: Content Type
- description: "Must be `application/json`."
- type: string
+ default: json
+ types:
+ json:
+ format: "application-json"
+ description: "The JSON object, as JSON text in bytes."
+ mediaType: application/json
out:
default: json
types:
diff --git
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index 88de20164..825647db4 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -585,7 +585,7 @@
"supportLevel" : "Stable",
"title" : "Crypto Decrypt Action",
"summary" : "Decrypts the body of each message that
`crypto-encrypt-action` encrypted, with the same algorithm and secret key.",
- "description" : "Decrypts the body of each message that
`crypto-encrypt-action` encrypted, with the same algorithm and secret
key.\n\nUse it to get back the original data that was encrypted with
`crypto-encrypt-action`, for example after reading it from storage or receiving
it from another system.\n\nInput: the encrypted data exactly as
`crypto-encrypt-action` produced it, as bytes or a stream. If it was encoded on
the way, for example in Base64, decode it first.\n\nOutput: the body [...]
+ "description" : "Decrypts the body of each message that
`crypto-encrypt-action` encrypted, with the same algorithm and secret
key.\n\nUse it to get back the original data that was encrypted with
`crypto-encrypt-action`, for example after reading it from storage or receiving
it from another system.\n\nInput: the encrypted data exactly as
`crypto-encrypt-action` produced it, as bytes or a stream. If it was encoded on
the way, for example in Base64, decode it first.\n\nOutput: the body [...]
"group" : "Actions",
"namespace" : "Transformation",
"provider" : "Apache Software Foundation"
@@ -1255,7 +1255,7 @@
"supportLevel" : "Stable",
"title" : "JSLT Action",
"summary" : "Turns each JSON message into new JSON with a JSLT
transformation, a query language for JSON that picks, renames and computes
fields.",
- "description" : "Turns each JSON message into new JSON with a JSLT
transformation, a query language for JSON that picks, renames and computes
fields.\n\nUse it to map the JSON of one system to the JSON another system
expects, for example to keep only some fields, rename them or count the items
of an order. To build text rather than JSON, use `mustache-template-action`;
`jolt-transformation-action` reshapes JSON with Jolt specifications
instead.\n\nInput: JSON text, bytes or a stream. [...]
+ "description" : "Turns each JSON message into new JSON with a JSLT
transformation, a query language for JSON that picks, renames and computes
fields.\n\nUse it to map the JSON of one system to the JSON another system
expects, for example to keep only some fields, rename them or count the items
of an order. To build text rather than JSON, use `mustache-template-action`;
`jolt-transformation-action` reshapes JSON with Jolt specifications
instead.\n\nInput: JSON text, as text, bytes or [...]
"group" : "Actions",
"namespace" : "Transformation",
"provider" : "Apache Software Foundation"
@@ -1445,7 +1445,7 @@
"supportLevel" : "Stable",
"title" : "Message Timestamp Router Action",
"summary" : "Changes the topic that `kafka-sink` writes a record to, to a
name made of the original topic name and a date read from a field of the JSON
body.",
- "description" : "Changes the topic that `kafka-sink` writes a record to,
to a name made of the original topic name and a date read from a field of the
JSON body.\n\nUse it to spread the records over one topic per day or per month
by a date in the data, such as the date of an order, in a flow from
`kafka-source` to `kafka-sink`. To use the time the record was written to Kafka
instead use `timestamp-router-action`.\n\nInput: a JSON object as JSON text,
with the `Content-Type` header se [...]
+ "description" : "Changes the topic that `kafka-sink` writes a record to,
to a name made of the original topic name and a date read from a field of the
JSON body.\n\nUse it to spread the records over one topic per day or per month
by a date in the data, such as the date of an order, in a flow from
`kafka-source` to `kafka-sink`. To use the time the record was written to Kafka
instead use `timestamp-router-action`.\n\nInput: a JSON object, as JSON text,
as bytes, as a Map or as parsed [...]
"group" : "Actions",
"namespace" : "Kafka",
"provider" : "Apache Software Foundation"
@@ -2165,7 +2165,7 @@
"supportLevel" : "Stable",
"title" : "Value to Key Action",
"summary" : "Sets the key of the Kafka record to some fields of the JSON
body, so that records with the same values in those fields get the same key.",
- "description" : "Sets the key of the Kafka record to some fields of the
JSON body, so that records with the same values in those fields get the same
key.\n\nUse it to take the key of the record from the data, before
`kafka-sink`, for example the customer of an order, so that all the records of
one customer go to the same partition and stay in order. To take the key from a
header instead use `set-kafka-key-action`.\n\nInput: a JSON object as JSON
text, with the `Content-Type` header s [...]
+ "description" : "Sets the key of the Kafka record to some fields of the
JSON body, so that records with the same values in those fields get the same
key.\n\nUse it to take the key of the record from the data, before
`kafka-sink`, for example the customer of an order, so that all the records of
one customer go to the same partition and stay in order. To take the key from a
header instead use `set-kafka-key-action`.\n\nInput: a JSON object, as JSON
text, as bytes, as a Map or as parsed [...]
"group" : "Actions",
"namespace" : "Kafka",
"provider" : "Apache Software Foundation"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/crypto-decrypt-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/crypto-decrypt-action.kamelet.yaml
index 04e039881..5faf4dd15 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/crypto-decrypt-action.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/crypto-decrypt-action.kamelet.yaml
@@ -38,9 +38,9 @@ spec:
Input: the encrypted data exactly as `crypto-encrypt-action` produced
it, as bytes or a stream. If it was encoded on the way, for example in Base64,
decode it first.
- Output: the body is the original data, as bytes (a stream). The headers
are kept.
+ Output: the body is the original data, as bytes (a stream), and the
`Content-Type` header is `application/octet-stream`. The other headers are kept.
- Good to know: the `Content-Type` header is kept as it comes, which after
`crypto-encrypt-action` is `application/octet-stream`: set it again to the type
of the original data when the next step needs it, for example with
`insert-header-action`. Data that was changed, or a different `algorithm`,
`mode` or `key` than when encrypting, fails the message with "Message
authentication failed". The key is a secret; keep it in a vault or a secret,
not in plain configuration.
+ Good to know: set the `Content-Type` header again to the type of the
original data when the next step needs it, for example with
`insert-header-action`. Data that was changed, or a different `algorithm`,
`mode` or `key` than when encrypting, fails the message with "Message
authentication failed". The key is a secret; keep it in a vault or a secret,
not in plain configuration.
required:
- algorithm
- key
@@ -63,6 +63,14 @@ spec:
format: password
x-descriptors:
- urn:camel:group:credentials
+ dataTypes:
+ in:
+ default: binary
+ types:
+ binary:
+ format: "application-octet-stream"
+ description: "The encrypted data, as bytes or a stream."
+ mediaType: application/octet-stream
dependencies:
- "camel:kamelet"
- "camel:crypto"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/crypto-encrypt-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/crypto-encrypt-action.kamelet.yaml
index 9ba413728..e01d59f1c 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/crypto-encrypt-action.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/crypto-encrypt-action.kamelet.yaml
@@ -64,6 +64,13 @@ spec:
x-descriptors:
- urn:camel:group:credentials
dataTypes:
+ in:
+ default: binary
+ types:
+ binary:
+ format: "application-octet-stream"
+ description: "The data to encrypt, as bytes or a stream."
+ mediaType: application/octet-stream
out:
default: binary
types:
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/jslt-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/jslt-action.kamelet.yaml
index 375f3854e..1601b9d4a 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/jslt-action.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/jslt-action.kamelet.yaml
@@ -36,11 +36,11 @@ spec:
Use it to map the JSON of one system to the JSON another system expects,
for example to keep only some fields, rename them or count the items of an
order. To build text rather than JSON, use `mustache-template-action`;
`jolt-transformation-action` reshapes JSON with Jolt specifications instead.
- Input: JSON text, bytes or a stream. The transformation sees the body as
`.` and a header as `$headers.name`, for example `{"customer": .name, "items":
size(.items), "source": $headers.origin}`.
+ Input: JSON text, as text, bytes or a stream, or parsed JSON as a
Jackson `JsonNode`, such as the output of `json-deserialize-action`. The
transformation sees the body as `.` and a header as `$headers.name`, for
example `{"customer": .name, "items": size(.items), "source": $headers.origin}`.
Output: the body is the result as JSON text in bytes, and the
`Content-Type` header is set to `application/json`. The other headers are kept.
- Good to know: parsed JSON (a Map or a JsonNode, such as the output of
`json-deserialize-action`) fails the message: give the JSON as text. A field
whose value is missing, such as a header that is not set, is left out of the
result. The transformation is loaded from a file, the classpath or a URL given
by the `template` option; it cannot come from the message. Headers that start
with `CamelJslt` are removed from the message first, so they cannot change what
the Kamelet does.
+ Good to know: a Map fails the message: give the JSON as text. A field
whose value is missing, such as a header that is not set, is left out of the
result. The transformation is loaded from a file, the classpath or a URL given
by the `template` option; it cannot come from the message. Headers that start
with `CamelJslt` are removed from the message first, so they cannot change what
the Kamelet does.
required:
- template
type: object
@@ -52,6 +52,13 @@ spec:
example: "file:///opt/templates/order.jslt"
pattern: "^(http|https|file|classpath|ref|bean)://.*"
dataTypes:
+ in:
+ default: binary
+ types:
+ binary:
+ format: "application-octet-stream"
+ description: "The JSON text, as bytes or a stream."
+ mediaType: application/octet-stream
out:
default: json
types:
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/json-deserialize-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/json-deserialize-action.kamelet.yaml
index 8e83c9ef4..3c6ba16fd 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/json-deserialize-action.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/json-deserialize-action.kamelet.yaml
@@ -42,6 +42,14 @@ spec:
Good to know: a body that is not valid JSON fails the message.
type: object
+ dataTypes:
+ in:
+ default: binary
+ types:
+ binary:
+ format: "application-octet-stream"
+ description: "The JSON text, as bytes or a stream."
+ mediaType: application/octet-stream
dependencies:
- "camel:kamelet"
- "camel:jackson3"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/message-timestamp-router-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/message-timestamp-router-action.kamelet.yaml
index d96c3371f..602c9a37e 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/message-timestamp-router-action.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/message-timestamp-router-action.kamelet.yaml
@@ -36,7 +36,7 @@ spec:
Use it to spread the records over one topic per day or per month by a
date in the data, such as the date of an order, in a flow from `kafka-source`
to `kafka-sink`. To use the time the record was written to Kafka instead use
`timestamp-router-action`.
- Input: a JSON object as JSON text, with the `Content-Type` header set to
`application/json`. The name of the topic is read from the `CamelKafkaTopic`
header, which `kafka-source` sets.
+ Input: a JSON object, as JSON text, as bytes, as a Map or as parsed JSON
(a Jackson `JsonNode`). The `Content-Type` header is not needed. The name of
the topic is read from the `CamelKafkaTopic` header, which `kafka-source` sets.
Output: the same JSON object, as JSON text in bytes, with `Content-Type`
set to `application/json`. When one of the `timestampKeys` fields is found, the
`CamelKafkaOverrideTopic` header is set to the new name, and `kafka-sink`
writes the record to that topic instead of its own `topic`.
@@ -70,15 +70,17 @@ spec:
type: object
dataTypes:
in:
+ default: json
+ types:
+ json:
+ format: "application-json"
+ description: "The JSON object, as JSON text in bytes."
+ mediaType: application/json
headers:
CamelKafkaTopic:
title: Kafka Topic
description: "The topic the record was read from, as `kafka-source`
sets it."
type: string
- Content-Type:
- title: Content Type
- description: "Must be `application/json`."
- type: string
out:
default: json
types:
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/nominatim-geocode-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/nominatim-geocode-action.kamelet.yaml
index 1223070ab..fbbd5e7b9 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/nominatim-geocode-action.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/nominatim-geocode-action.kamelet.yaml
@@ -51,6 +51,13 @@ spec:
example: "https://nominatim.openstreetmap.org"
type: string
dataTypes:
+ in:
+ default: text
+ types:
+ text:
+ format: "text-plain"
+ description: "The place name or address to look up."
+ mediaType: text/plain
out:
default: json
headers:
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/ogcapi-features-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/ogcapi-features-action.kamelet.yaml
index f63c0df75..97018547b 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/ogcapi-features-action.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/ogcapi-features-action.kamelet.yaml
@@ -147,6 +147,14 @@ spec:
example: orders.write
x-descriptors:
- urn:camel:group:credentials
+ dataTypes:
+ in:
+ default: text
+ types:
+ text:
+ format: "text-plain"
+ description: "More query parameters, such as `name=Lake Baikal`, or
an empty body."
+ mediaType: text/plain
types:
in:
mediaType: text/plain
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/value-to-key-action.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/value-to-key-action.kamelet.yaml
index 0f83428d2..604971b8c 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/value-to-key-action.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/value-to-key-action.kamelet.yaml
@@ -36,7 +36,7 @@ spec:
Use it to take the key of the record from the data, before `kafka-sink`,
for example the customer of an order, so that all the records of one customer
go to the same partition and stay in order. To take the key from a header
instead use `set-kafka-key-action`.
- Input: a JSON object as JSON text, with the `Content-Type` header set to
`application/json`.
+ Input: a JSON object, as JSON text, as bytes, as a Map or as parsed JSON
(a Jackson `JsonNode`). The `Content-Type` header is not needed.
Output: the same JSON object, as JSON text in bytes, with `Content-Type`
set to `application/json`. The `CamelKafkaKey` header, which `kafka-sink` uses
as the key of the record, is set to a Map of the fields named in `fields` and
their values.
@@ -52,11 +52,12 @@ spec:
type: object
dataTypes:
in:
- headers:
- Content-Type:
- title: Content Type
- description: "Must be `application/json`."
- type: string
+ default: json
+ types:
+ json:
+ format: "application-json"
+ description: "The JSON object, as JSON text in bytes."
+ mediaType: application/json
out:
default: json
types:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.citrus.it.yaml
index ec540cdcc..20b47de0b 100644
---
a/tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.citrus.it.yaml
@@ -52,6 +52,11 @@ actions:
receiveRequest:
POST:
path: "/result"
+ headers:
+ - name: "X-Body-Type"
+ value: 'org.apache.camel.converter.stream.InputStreamCache'
+ - name: "X-Content-Type"
+ value: 'ct=application/octet-stream'
body:
data: |
${plaintext}
diff --git
a/tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.yaml
index 0ee353447..1c57ccc42 100644
---
a/tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.yaml
@@ -34,7 +34,14 @@
parameters:
algorithm: '{{crypto.algorithm}}'
key: '{{crypto.key}}'
- # the encrypted data is application/octet-stream, which decrypting
keeps: the text is text again
+ # what the Kamelet gives: the Java type of the body and the
Content-Type
+ - setHeader:
+ name: X-Body-Type
+ simple: "${body.getClass().getName()}"
+ - setHeader:
+ name: X-Content-Type
+ simple: "ct=${header.Content-Type}"
+ # the decrypted data is application/octet-stream: the text is text
again
- to:
uri: "kamelet:insert-header-action"
parameters:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/kafkarouter/value-to-key-action-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/kafkarouter/value-to-key-action-route.yaml
index df0ed1069..23617a5db 100644
---
a/tests/camel-kamelets-itest/src/test/resources/kafkarouter/value-to-key-action-route.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/kafkarouter/value-to-key-action-route.yaml
@@ -24,9 +24,6 @@
steps:
- setBody:
constant: '{"id":7,"customer":"acme","total":12}'
- - setHeader:
- name: Content-Type
- constant: 'application/json'
- to:
uri: "kamelet:value-to-key-action"
parameters:
diff --git
a/tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.citrus.it.yaml
b/tests/camel-kamelets-itest/src/test/resources/transformation/jslt-action-jsonnode-route.citrus.it.yaml
similarity index 62%
copy from
tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.citrus.it.yaml
copy to
tests/camel-kamelets-itest/src/test/resources/transformation/jslt-action-jsonnode-route.citrus.it.yaml
index ec540cdcc..6df6b8ff0 100644
---
a/tests/camel-kamelets-itest/src/test/resources/crypto/crypto-action-route.citrus.it.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/transformation/jslt-action-jsonnode-route.citrus.it.yaml
@@ -15,47 +15,33 @@
# limitations under the License.
# ---------------------------------------------------------------------------
-name: crypto-action-route-test
-variables:
- - name: "crypto.algorithm"
- value: "AES"
- - name: "crypto.key"
- value: "0123456789abcdef"
- - name: "plaintext"
- value: "Camel Kamelets crypto rocks!"
+name: jslt-action-jsonnode-route-test
actions:
- - createVariables:
- variables:
- - name: "http.server.url"
- value: "http://localhost:${http.server.port}"
- # Create Camel JBang integration
- camel:
cli:
run:
waitForRunningState: false
+ resources:
+ - "templates/order.jslt"
integration:
- file: "crypto/crypto-action-route.yaml"
+ file: "transformation/jslt-action-jsonnode-route.yaml"
systemProperties:
properties:
- name: "http.sink.url"
- value: "${http.server.url}"
- - name: "crypto.algorithm"
- value: "${crypto.algorithm}"
- - name: "crypto.key"
- value: "${crypto.key}"
- - name: "input"
- value: "${plaintext}"
+ value: "http://localhost:${http.server.port}"
- # Verify Http request receives the decrypted plaintext
- http:
server: "httpServer"
receiveRequest:
POST:
path: "/result"
+ headers:
+ - name: "X-Body-Type"
+ value: '[B'
+ - name: "X-Content-Type"
+ value: 'ct=application/json'
body:
- data: |
- ${plaintext}
-
+ data: '{"customer":"Ann","source":"web"}'
- http:
server: "httpServer"
sendResponse:
@@ -63,5 +49,3 @@ actions:
status: 200
reasonPhrase: "OK"
version: "HTTP/1.1"
- body:
- data: "Thank You!"
diff --git
a/tests/camel-kamelets-itest/src/test/resources/kafkarouter/value-to-key-action-route.yaml
b/tests/camel-kamelets-itest/src/test/resources/transformation/jslt-action-jsonnode-route.yaml
similarity index 75%
copy from
tests/camel-kamelets-itest/src/test/resources/kafkarouter/value-to-key-action-route.yaml
copy to
tests/camel-kamelets-itest/src/test/resources/transformation/jslt-action-jsonnode-route.yaml
index df0ed1069..468454cec 100644
---
a/tests/camel-kamelets-itest/src/test/resources/kafkarouter/value-to-key-action-route.yaml
+++
b/tests/camel-kamelets-itest/src/test/resources/transformation/jslt-action-jsonnode-route.yaml
@@ -22,23 +22,24 @@
period: "1000"
repeatCount: 1
steps:
- - setBody:
- constant: '{"id":7,"customer":"acme","total":12}'
- setHeader:
- name: Content-Type
- constant: 'application/json'
+ name: origin
+ constant: 'web'
+ - setBody:
+ constant: '{"name":"Ann","items":[{"price":2},{"price":3}]}'
+ # parsed JSON: the Kamelet writes it as JSON text before the
transformation
- to:
- uri: "kamelet:value-to-key-action"
+ uri: "kamelet:json-deserialize-action"
+ - to:
+ uri: "kamelet:jslt-action"
parameters:
- fields: 'id'
+ template: 'classpath:order.jslt'
+ # what the Kamelet gives: the Java type of the body and the
Content-Type
- setHeader:
name: X-Body-Type
simple: "${body.getClass().getName()}"
- setHeader:
name: X-Content-Type
simple: "ct=${header.Content-Type}"
- - setHeader:
- name: X-Kafka-Key
- simple: '${header.CamelKafkaKey}'
- to:
uri: "{{http.sink.url}}/result"