Apache Camel - Why is Rest OpenAPI appending basePath twice

26 Views Asked by At

I have a route that uses the camel-rest-openapi component to call an operation defined in the Petstore OpenAPI Spec. The component is appending the basePath multiple times when attempting to run the route causing a HTTP 404 response.

ex: petstore3.swagger.io /api/v3/api/v3 /pet/findByStatus?status=available

Below is the route definition using Yaml DSL and the output from camel jbang.

Route:

- from:
    uri: "timer:fetchPets?repeatCount=1"
    description: "Periodically fetches list of pets"
    steps:
      - to: "rest-openapi:https://petstore3.swagger.io/api/v3/openapi.json#findPetsByStatus?status=available&componentName=https"
      - log: "Received pets list: ${body}"

Output log:

jake@localhost ~ % camel run sandbox.yaml
[jbang] Resolving dependencies...
[jbang]    org.apache.camel:camel-bom:4.5.0@pom
[jbang]    org.apache.camel:camel-jbang-core:4.5.0
[jbang]    org.apache.camel.kamelets:camel-kamelets:4.4.1
[jbang] Dependencies resolved
[jbang] Building jar for CamelJBang.java...
Note: Annotation processing is enabled because one or more processors were found
  on the class path. A future release of javac may disable annotation processing
  unless at least one processor is specified by name (-processor), or a search
  path is specified (--processor-path, --processor-module-path), or annotation
  processing is enabled explicitly (-proc:only, -proc:full).
  Use -Xlint:-options to suppress this message.
  Use -proc:none to disable annotation processing.
2024-03-28 10:38:46.875  INFO 78257 --- [           main] org.apache.camel.main.MainSupport   : Apache Camel (JBang) 4.5.0 is starting
2024-03-28 10:38:46.973  INFO 78257 --- [           main] org.apache.camel.main.MainSupport   : Using Java 21.0.1 with PID 78257. Started by jake in /Users/jake
2024-03-28 10:38:47.036  INFO 78257 --- [           main] apache.camel.main.ProfileConfigurer : The application is starting with profile: dev
2024-03-28 10:38:47.127  INFO 78257 --- [           main] mel.cli.connector.LocalCliConnector : Management from Camel JBang enabled
2024-03-28 10:38:47.829  INFO 78257 --- [           main] .download.MavenDependencyDownloader : Downloaded: org.apache.camel:camel-rest-openapi:4.5.0 (took: 679ms) from: central@https://repo1.maven.org/maven2
2024-03-28 10:38:47.848  INFO 78257 --- [           main] el.impl.engine.AbstractCamelContext : Apache Camel 4.5.0 (sandbox) is starting
2024-03-28 10:38:48.830  INFO 78257 --- [           main] .download.MavenDependencyDownloader : Downloaded: org.apache.camel:camel-http:4.5.0 (took: 569ms) from: central@https://repo1.maven.org/maven2
2024-03-28 10:38:48.904  INFO 78257 --- [           main] el.impl.engine.AbstractCamelContext : Routes startup (total:1)
2024-03-28 10:38:48.905  INFO 78257 --- [           main] el.impl.engine.AbstractCamelContext :     Started route1 (timer://fetchPets)
2024-03-28 10:38:48.905  INFO 78257 --- [           main] el.impl.engine.AbstractCamelContext : Apache Camel 4.5.0 (sandbox) started in 1s56ms (build:0ms init:0ms start:1s56ms)
2024-03-28 10:38:50.136 ERROR 78257 --- [mer://fetchPets] or.errorhandler.DefaultErrorHandler : Failed delivery for (MessageId: D038A8A058C3548-0000000000000000 on ExchangeId: D038A8A058C3548-0000000000000000). Exhausted after delivery attempt: 1 caught: org.apache.camel.http.base.HttpOperationFailedException: HTTP operation failed invoking https://petstore3.swagger.io/api/v3/api/v3/pet/findByStatus?status=available with statusCode: 404

Attempted to use both v2 and v3 of the Petstore spec. Also tried to override the basePath in spec by setting the basePath property in application.properties and as a query parameter on the camel-rest-openapi component.

0

There are 0 best solutions below