Henrik Karlsson created CAMEL-17202:
---------------------------------------
Summary: If two openapi spec uses the same path only one rest
endpoint is created
Key: CAMEL-17202
URL: https://issues.apache.org/jira/browse/CAMEL-17202
Project: Camel
Issue Type: Bug
Components: camel-rest-openapi
Affects Versions: 3.13.0
Reporter: Henrik Karlsson
If two openapi spec uses the same method, basePath and uriTemplate the
componentEndpointUri will be the same. Then the second endpoint is created the
first one is found in the camel context and the host property is overwritten.
This causes all calls to these operations in routes goes to the second api.
API One:
host: [https://api.one.com|https://api.one.com/]
method: GET
basePath: /api
uriTemplate: /users/\{email}
title: api-one
version: 1.0.2
API Two:
host: [https://api.two.com|https://api.one.com/]
method: GET
basePath: /api
uriTemplate: /users/\{email}
title: api-two
version: 2.0.1
In RestOpenApiEndpoint.createProducerFor() the componentEndpointUri is created
like this:
{code:java}
final String componentEndpointUri = "rest:" + method + ":" + basePath + ":" +
uriTemplate {code}
For both of the operations described above the componentEndpointUri will be
{noformat}
"rest:GET:/api:/users/{email}"{noformat}
When the camelContext.getEndpoint is called with this uri for API Two the
endpoint for created for API One is returned instead of creating a new and the
host parameter is set to '[https://api.two.com'.|https://api.two.com'./]
To solve this I've added title and version the openapi spec as query parameters
to the componentEndpointUri:
{code:java}
final String componentEndpointUri = "rest:" + method + ":" + basePath + ":" +
uriTemplate
+ "?title=" + openapi.info.title + "&version=" + openapi.info.version;
{code}
Title and version are required in OpenAPI 3.x so they should always be
available.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)