[ 
https://issues.apache.org/jira/browse/CAMEL-21057?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Lukas Lowinger updated CAMEL-21057:
-----------------------------------
     Attachment: rest-openapi-camel.zip
    Description: 
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

  was:
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}


> 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
>    Affects Versions: 3.18.8
>            Reporter: Lukas Lowinger
>            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)

Reply via email to