This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new a3d00dc  CAMEL-17202: camel-rest-openapi - If two openapi spec uses 
the same path only one rest endpoint is created. Thanks to Henrik Karlsson for 
the example that reproduces this bug.
a3d00dc is described below

commit a3d00dcc3557bc73314e26f43fe6ebc31a8fcafb
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 22 14:45:41 2021 +0100

    CAMEL-17202: camel-rest-openapi - If two openapi spec uses the same path 
only one rest endpoint is created. Thanks to Henrik Karlsson for the example 
that reproduces this bug.
---
 .../camel/component/rest/openapi/RestOpenApiEndpoint.java  | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git 
a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java
 
b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java
index 330adb9..17b6d1e 100644
--- 
a/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java
+++ 
b/components/camel-rest-openapi/src/main/java/org/apache/camel/component/rest/openapi/RestOpenApiEndpoint.java
@@ -340,15 +340,19 @@ public final class RestOpenApiEndpoint extends 
DefaultEndpoint {
             final Document openapi, final OasOperation operation, final String 
method,
             final String uriTemplate)
             throws Exception {
-        final String basePath = determineBasePath(openapi);
-        final String componentEndpointUri = "rest:" + method + ":" + basePath 
+ ":" + uriTemplate;
 
-        final CamelContext camelContext = getCamelContext();
-
-        final Endpoint endpoint = 
camelContext.getEndpoint(componentEndpointUri);
+        CamelContext camelContext = getCamelContext();
 
         Map<String, Object> params = determineEndpointParameters(openapi, 
operation);
         boolean hasHost = params.containsKey("host");
+
+        String basePath = determineBasePath(openapi);
+        String componentEndpointUri = "rest:" + method + ":" + basePath + ":" 
+ uriTemplate;
+        if (hasHost) {
+            componentEndpointUri += "?host=" + params.get("host");
+        }
+
+        Endpoint endpoint = camelContext.getEndpoint(componentEndpointUri);
         // let the rest endpoint configure itself
         endpoint.configureProperties(params);
 

Reply via email to