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

   [CAMEL-25321](https://issues.apache.org/jira/browse/CAMEL-25321)
   
   **The problem:** with `requestValidationEnabled=true` the rest-openapi 
producer validates a request before sending it: the content type, a required 
body, JSON syntax, and required query and header parameters. It did not check 
**path parameters**. A call to `/stock/{sku}/reserve` without a `sku` header 
passed validation, went out with the literal `{sku}` in the path, and the 
service answered 404. CAMEL-24986 logs a WARN when that happens, but the 
request is still sent.
   
   **The change:** every path parameter is required in OpenAPI, so the 
validator now checks each placeholder of the operation's path.
   - **Where it gets the names:** from the path template, so a parameter 
declared on the path item counts too.
   - **Where it looks for a value:** a header, an exchange variable or an 
endpoint parameter, in the same way as for query parameters.
   - **When there is none:**
     ```
     Path parameter 'sku' is required but none found: set the header sku, or an 
exchange variable of that name, before the call.
     ```
   - **Several problems:** each missing parameter or header is a separate 
validation error, so all of them are reported.
   - **Default behaviour:** unchanged. Validation is still off by default.
   - **Docs:** the "Request validation" section of the component page lists 
path parameters.
   
   **Tests** (`RestOpenApiRequestValidationTest`):
   - a missing `petId` fails with the message above;
   - a `petId` from an exchange variable passes;
   - a request missing both the path parameter and a required header reports 
both errors.
   
   `requestValidationRequiredHeaderParamsNotPresent` sent no `id` by accident; 
it now sets one so that it tests only the missing header. The rest-openapi 
suite passes (165 tests).
   
   Found in the local-model benchmark (contracts/openapi-client). Related: 
CAMEL-24986, CAMEL-24992.
   
   🤖 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