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

   [CAMEL-25862](https://issues.apache.org/jira/browse/CAMEL-25862): the 
validator refuses a rest-openapi call whose body is parsed data (a Map or a 
List) when the operation sends a body (CAMEL-24844, CAMEL-25762). The hint said 
"add marshal: json before this step, or let the REST binding write it". A model 
follows the first advice literally and marshals the data it has. But the 
request of an operation is rarely the data as it is.
   
   In the benchmark example contracts-openapi-client, each line of an order 
(sku, qty) is sent to reserveStock, whose request needs orderId and qty. The 
marshalled line has no orderId, so every call was answered 400, and the 400 
answer is not in the log of the app. The step fell from 9 of 10 runs (r17) to 3 
of 8 and 8 of 12 (r18, r19) once this hint came in. In r17, the runtime error 
said "or set the body to the JSON text", and all 5 runs that met it recovered.
   
   - For a rest-openapi call with JSON data, the hint now reads:
     > set the body to the JSON text of the request before this step (it needs 
orderId, qty), such as with setBody and simple: '{"orderId": ..., "qty": ...}', 
or add marshal: json before this step when the data has the fields of the 
request, or let the REST binding write it (bindingMode: json)
   - The fields come from the specification: `OpenApiVerbs.requestFields` reads 
the required properties of each operation's JSON request schema, following a 
`$ref` to the schemas of the components. `ProjectFacts` carries them (a new 
component; the constructor without it stays). Without known fields, the hint 
shows a generic example.
   - The other hints are unchanged: a file, an http POST, the reply of a REST 
route, and XML data.
   
   ## Tests
   
   - `TextBodyFlowTest` (camel-yaml-dsl-validator): the hint of a rest-openapi 
call; new: the split of order lines (the benchmark's shape) names orderId and 
qty.
   - `ValidatorFactsTest` (camel-jbang-core): new: the request fields of a JSON 
specification with a `$ref` and of a YAML specification with an inline schema, 
and none for a specification without request schemas; the hint through 
`SourceValidator` names the fields.
   - All tests of camel-yaml-dsl-validator (264), camel-jbang-core (2362 + 237) 
and camel-jbang-mcp (503) pass.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m
   


-- 
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