Claus Ibsen created CAMEL-25321:
-----------------------------------

             Summary: camel-rest-openapi - client request validation checks the 
path parameters too
                 Key: CAMEL-25321
                 URL: https://issues.apache.org/jira/browse/CAMEL-25321
             Project: Camel
          Issue Type: Improvement
          Components: camel-rest-openapi
            Reporter: Claus Ibsen


With {{requestValidationEnabled=true}} the rest-openapi producer validates the 
request before sending: content type, required body, JSON syntax, required 
query parameters and required header parameters. Path parameters are not 
checked. A call whose path parameter has no value, such as 
{{/stock/\{sku\}/reserve}} without a header {{sku}}, passes the validation and 
goes out with the literal {{\{sku\}}} in the path; the service answers 404. 
CAMEL-24986 logs a WARN about it at send time, but the request is still sent 
and the 404 is the error the user (or a model) sees.

Every path parameter is required in OpenAPI. Proposal: the validator also 
checks the placeholders of the operation's path (taken from the path template, 
so a parameter declared on the path item counts too): each needs a value from a 
header, an exchange variable or an endpoint parameter, as for query parameters; 
otherwise the validation fails with {{Path parameter 'sku' is required but none 
found: set the header sku, or an exchange variable of that name, before the 
call.}}

Found in the local-model benchmark (contracts/openapi-client). Related: 
CAMEL-24986 (runtime WARN), CAMEL-24992 (validator check before the route runs).



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

Reply via email to