davsclaus opened a new pull request, #30476:
URL: https://github.com/apache/camel/pull/30476

   [CAMEL-27271](https://issues.apache.org/jira/browse/CAMEL-27271)
   
   > **Stacked on #30475 (CAMEL-27270).** The base is its branch: both change 
`JsonDataTypeTransformer`. I'll retarget to `main` once #30475 merges, which is 
when CI builds it.
   
   ### The problem
   A Kamelet that gives a more specific media type can't declare an out data 
type today, because the data type replaces it:
   - **JSON:** `application-json` always sets `Content-Type: application/json`. 
So the `application/fhir+json` of `fhir-source`, or the `application/geo+json` 
of `ogcapi-features-action`, is lost.
   - **Avro and Protobuf:** `avro-serialize-action` and 
`protobuf-serialize-action` marshal and then set `application/avro` or 
`application/protobuf`. As an out data type, `avro-binary` and 
`protobuf-binary` would need the schema exchange property. They would then read 
those bytes back, write them again, and set `avro/binary` or `protobuf/binary`.
   
   ### The change
   - **`application-json`** (`JsonDataTypeTransformer`, camel-jackson and 
camel-jackson3):
     - it keeps an existing `application/*+json` Content-Type, with its 
parameters. Any other one, including `application/json; charset=…`, still 
becomes `application/json`;
     - the CAMEL-27270 rule, which keeps a Json value given as text, applies to 
a `+json` media type too.
   - **`avro-binary`** (camel-jackson-avro and camel-jackson3-avro): a byte 
array or stream body whose Content-Type is `application/avro` or `avro/binary` 
is Avro already. It is kept as it is, with that Content-Type, and needs no 
schema. Every other body is serialized as before.
   - **`protobuf-binary`** (camel-jackson-protobuf and 
camel-jackson3-protobuf): the same, for `application/protobuf` and 
`protobuf/binary`.
   - **Body types:** they say this, and `transformerOut` of the two binary 
types also lists `stream`. The generated metadata and the catalog copies are 
updated.
   
   This is part of the data types work for the Kamelet catalog 
(apache/camel-kamelets#3117, CAMEL-25928). It unblocks `fhir-source`, the `out` 
of `ogcapi-features-action`, `avro-serialize-action` and 
`protobuf-serialize-action`.
   
   ### Tests
   - `JsonDataTypeTransformerTest` (both modules):
     - `application/fhir+json` and `application/geo+json; charset=UTF-8` are 
kept, for a Map and for a Json value given as text;
     - `text/plain`, `application/xml` and `application/json; charset=UTF-8` 
become `application/json`.
   - `AvroBinaryDataTypeTransformerTest`, 
`ProtobufBinaryDataTypeTransformerTest` (both modules each):
     - bytes and a stream with either Content-Type, in any case and with 
parameters, are kept as the same instance, with no schema;
     - other bytes still need the schema;
     - the body types.
   - Run locally:
     - camel-jackson, camel-jackson3, camel-jackson-avro, camel-jackson3-avro, 
camel-jackson-protobuf, camel-jackson3-protobuf: all tests pass;
     - camel-yaml-dsl-validator: all 374 pass, against a catalog jar packaged 
with this change.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 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]

Reply via email to