[ https://issues.apache.org/jira/browse/CAMEL-21057?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17873098#comment-17873098 ]
Zheng Feng commented on CAMEL-21057: ------------------------------------ Yeah, it does not handle the relative url correctly. Refer to the spec https://swagger.io/docs/specification/api-host-and-base-path/ {noformat} The URLs in the servers array can be relative, such as /v2. In this case, the URL is resolved against the server that hosts the given OpenAPI definition.{noformat} > REST OpenApi fails to resolve host from the URL > ----------------------------------------------- > > Key: CAMEL-21057 > URL: https://issues.apache.org/jira/browse/CAMEL-21057 > Project: Camel > Issue Type: Bug > Components: camel-rest-openapi > Affects Versions: 3.18.8, 4.7.0 > Reporter: Lukas Lowinger > Assignee: Zheng Feng > Priority: Major > Attachments: rest-openapi-camel.zip > > > Given simple route > {code} > private final String openApiJsonUrl = > "http://localhost:8080/api/v3/openapi.json"; > String a = "{\n" + " \"id\": 13,\n" + " \"name\": \"kooo\",\n" + " > \"category\": {\n" + " \"id\": 1,\n" + " \"name\": \"Dogs\"\n" + " > }\n" + "}"; > @Override > public void configure() throws Exception { > > from("timer:test?repeatCount=1").setBody(simple(a)).setHeader(Exchange.CONTENT_TYPE, > simple("application/json")).to("rest-openapi:#addPet?specificationUri=RAW(" > + openApiJsonUrl + ")").to("direct:readPet"); > from("direct:readPet").setHeader("petId", > simple("13")).to("rest-openapi:#getPetById?specificationUri=RAW(" + > openApiJsonUrl + ")"); > } > {code} > I get > {code} > Caused by: java.net.MalformedURLException: no protocol: /api/v3 > at java.net.URL.<init> (URL.java:674) > at java.net.URL.<init> (URL.java:569) > at java.net.URL.<init> (URL.java:516) > at > org.apache.camel.component.rest.openapi.RestOpenApiEndpoint.determineHost > (RestOpenApiEndpoint.java:590) > at > org.apache.camel.component.rest.openapi.RestOpenApiEndpoint.determineEndpointParameters > (RestOpenApiEndpoint.java:459) > {code} > Reproducer: > # Unzip [^rest-openapi-camel.zip] > # Run `docker run -p 8080:8080 swaggerapi/petstore3` > # mvn camel:run -- This message was sent by Atlassian Jira (v8.20.10#820010)