You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2025/05/29 05:49:00 UTC
[jira] [Commented] (CAMEL-22117) camel-openapi-validator doesn't use query params or headers for validation
[ https://issues.apache.org/jira/browse/CAMEL-22117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17954856#comment-17954856 ]
Claus Ibsen commented on CAMEL-22117:
-------------------------------------
Thanks are your PRs on the way as we will do a 4.10.x patch release soon
> 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
> Fix For: 4.13.0
>
>
> 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)