[ 
https://issues.apache.org/jira/browse/CAMEL-22117?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-22117:
--------------------------------
    Priority: Minor  (was: Major)

> camel-openapi-validator doesn't use query params or headers for validation
> --------------------------------------------------------------------------
>
>                 Key: CAMEL-22117
>                 URL: https://issues.apache.org/jira/browse/CAMEL-22117
>             Project: Camel
>          Issue Type: Bug
>    Affects Versions: 4.10.4, 4.11.0
>            Reporter: Bjorn Beskow
>            Priority: Minor
>
> camel-openapi-validator doesn't provide query params or headers to the 
> underlying OpenApiInteractionValidator for use in validation. Hence if the 
> openapi specification contains required headers or query params, the 
> validation will erroneously fail even if the query params or headers are 
> present. They should be added to the context prior to the validation:
> {code:java}
> SimpleRequest.Builder builder = ...
> // Use all non-Camel headers
> for (Entry<String, Object> header : 
> exchange.getMessage().getHeaders().entrySet()) {
>     boolean isCamelHeader = header.getKey().startsWith("Camel")
>             || header.getKey().startsWith("camel")
>             || header.getKey().startsWith("org.apache.camel.");
>     if (!isCamelHeader) {
>         builder.withHeader(header.getKey(), header.getValue().toString());
>     }
> }
> // Use query parameters, if present
> String query = exchange.getMessage().getHeader(Exchange.HTTP_QUERY, 
> String.class);
> if (query != null) {
>     String[] params = query.split("&");
>     for (String param : params) {
>         String[] keyValue = param.split("=");
>         if (keyValue.length == 2) {
>             builder.withQueryParam(keyValue[0], keyValue[1]);
>         } else if (keyValue.length == 1) {
>             builder.withQueryParam(keyValue[0], "");
>         }
>     }
> }
> {code}
> I will submit a merge request containing the above patch.



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

Reply via email to