You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2024/11/22 11:41:23 UTC
(camel) branch camel-4.8.x updated: Fix for RestOpenApiProcessor for parsing path variables from the http request uri succesfully. (#16220) (#16346)
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch camel-4.8.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.8.x by this push:
new 1385c8fa874 Fix for RestOpenApiProcessor for parsing path variables from the http request uri succesfully. (#16220) (#16346)
1385c8fa874 is described below
commit 1385c8fa874639682490ed36b846cdcf24b3a354
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Nov 22 12:41:16 2024 +0100
Fix for RestOpenApiProcessor for parsing path variables from the http request uri succesfully. (#16220) (#16346)
* Update RestOpenApiProcessor.java
if uri is not starting with slash then remove the slash in the consumerPath from the openApi spec, because if there is any path variables (/../{id}) in the consumerPath and the uri does not start with "/" then HttpHelper.evalPlaceholders method throws an ArrayIndexOutOfBoundsException.
* code style fixes and added null check the uri.
Co-authored-by: egekaraosmanoglu <eg...@gmail.com>
---
.../camel/component/rest/openapi/RestOpenApiProcessor.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProcessor.java b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProcessor.java
index a947a2505cb..d1c5d356500 100644
--- a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProcessor.java
+++ b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiProcessor.java
@@ -127,8 +127,15 @@ public class RestOpenApiProcessor extends DelegateAsyncProcessor implements Came
if (m instanceof RestOpenApiConsumerPath rcp) {
Operation o = rcp.getConsumer();
+ String consumerPath = rcp.getConsumerPath();
+
+ //if uri is not starting with slash then remove the slash in the consumerPath from the openApi spec
+ if (consumerPath.startsWith("/") && uri != null && !uri.startsWith("/")) {
+ consumerPath = consumerPath.substring(1);
+ }
+
// map path-parameters from operation to camel headers
- HttpHelper.evalPlaceholders(exchange.getMessage().getHeaders(), uri, rcp.getConsumerPath());
+ HttpHelper.evalPlaceholders(exchange.getMessage().getHeaders(), uri, consumerPath);
// process the incoming request
return restOpenapiProcessorStrategy.process(openAPI, o, verb, uri, rcp.getBinding(), exchange, callback);