Federico Mariani created CAMEL-24114:
----------------------------------------

             Summary: camel-rest-openapi: requestValidationEnabled rejects 
requests whose required query parameters are supplied as endpoint literals or 
exchange variables
                 Key: CAMEL-24114
                 URL: https://issues.apache.org/jira/browse/CAMEL-24114
             Project: Camel
          Issue Type: Bug
          Components: camel-rest-openapi
    Affects Versions: 4.21.0
            Reporter: Federico Mariani


h3. Problem
{{DefaultRequestValidator}} (validator/DefaultRequestValidator.java:98-107) 
checks required query parameters (and headers) only via 
{{message.getHeader(parameter.getName())}}. The component supports two other 
documented ways of supplying query parameter values that the outgoing request 
will actually contain: (a) literal values in the rest-openapi endpoint URI 
({{queryParameter}} -> {{literalQueryParameterValue}} bakes e.g. 
{{status=available}} into the delegate's {{queryParameters}}), and (b) exchange 
variables ({{RestProducer.createQueryParameters}} falls back to 
{{exchange.getVariable(key)}}). In both cases the header is absent, so 
validation fails even though the request is valid.

h3. Failure scenario
{{to("rest-openapi:petstore.json#findPetsByStatus?status=available&requestValidationEnabled=true")}};
 the spec declares {{status}} as a required query param -> every exchange fails 
with {{RestOpenApiValidationException: Query parameter 'status' is required but 
none found.}} while the same URI without validation correctly sends {{GET 
/pet/findByStatus?status=available}}.

h3. History
{{RestOpenApiRequestValidationTest}} only ever supplies required query params 
via headers, so the broken combination is untested.

h3. Fix direction
Pass the resolved literal {{queryParameters}} (or the endpoint parameters map) 
into {{RestOpenApiOperation}}/the validator so literals count as present, and 
consult {{exchange.getVariable(name)}} the same way {{RestProducer}} does.

----
_This issue was researched and filed by Claude Code on behalf of [~croway] 
(GitHub: Croway), as part of a deep code review of camel-rest-openapi and 
camel-openapi-java on main (4.22.0-SNAPSHOT). Full findings document available 
on request._



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to