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

   [CAMEL-27268](https://issues.apache.org/jira/browse/CAMEL-27268)
   
   > **Stacked on #30471 (CAMEL-27266).** The base is its branch, so only this 
change shows. I'll retarget to `main` once #30471 merges, which is when CI 
builds it.
   
   ### The problem
   The `@BodyTypes` of the `text-plain` data type (`StringDataTypeTransformer`) 
say its `transformerIn` is `any`. So the YAML body type validator never warned 
when parsed data (a Map or a List) came before:
   - a Kamelet whose `spec.dataTypes.in.default` is `text`;
   - `transformDataType: text-plain`.
   
   At runtime that body becomes its Java `toString()`, such as `{status=ok}`, 
which the Kamelet descriptions warn about.
   
   ### The change
   - **`text-plain` metadata:** `transformerIn` is now text, bytes, a stream, a 
file, a value (such as a number, which becomes `"5"`) or no body. The 
description says that a Map, a List or an object would become its `toString()`. 
The generated metadata and its catalog copy are updated.
   - **Validator:** a new `CatalogBodyTypes.Answer.onlyPayloadOrValue()` (a 
payload, maybe also a value or no body). `TextBodyFlow.needsText` uses it for 
the in data type of a Kamelet and for `transformDataType`, so a value keeps 
passing and parsed data is reported with the hint to marshal it first. The 
checks for producers and unmarshal keep `onlyPayload()`.
   - **`testTransformDataTypeLeavesWhatItsTransformerMakes` (from 
CAMEL-25928):** it asserted that `unmarshal: json` followed by 
`transformDataType: text/plain` gives no warning. That was a consequence of 
`any`, and it now warns. Its second case, which checks what `text-plain` leaves 
behind, starts from file text instead.
   
   This is part of the data types work for the Kamelet catalog 
(apache/camel-kamelets#3117, CAMEL-25928). It gives the validator something to 
check for the `text` in defaults that the Kamelets will declare.
   
   ### Tests
   - `TextBodyFlowTest`:
     - parsed data before a Kamelet with a `text-plain` in type warns, and 
marshalled text doesn't;
     - parsed data before `transformDataType: text-plain` warns.
   - `StringDataTypeTransformerTest`: the narrowed `transformerIn`.
   - Run locally, against a catalog jar packaged with this change:
     - camel-yaml-dsl-validator: all 376 pass;
     - camel-jbang-plugin-validate: 24 pass;
     - camel-jbang-core: `KameletChecksTest`, `ValidatorFactsTest`, 
`HttpEndpointsTest`: 62 pass;
     - camel-core: the data type transformer tests, `EipBodyTypesTest`, 
`TransformerContractTest`, `DataTypeProcessorTest`: 38 pass.
   
   _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