Skip to content

Commit

Permalink
Fix for RestOpenApiProcessor for parsing path variables from the http…
Browse files Browse the repository at this point in the history
… request uri succesfully. (#16220)

* 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.
  • Loading branch information
egekaraosmanoglu authored and squakez committed Nov 21, 2024
1 parent 22a9af2 commit 7f8d41e
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,15 @@ public boolean process(Exchange exchange, AsyncCallback callback) {
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);
Expand Down

0 comments on commit 7f8d41e

Please sign in to comment.