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

Thomas Diesler updated CAMEL-12943:
-----------------------------------
    Description: 
With this code

 
{code:java}
        rest("/customers").description("Customers REST service")
            .get("/\{id}")
                .bindingMode(RestBindingMode.auto)
                .id("getCustomerById")
                .description("Retrieves a customer for the specified id")
                .outType(Customer.class)
                .route()
                    .process(exchange -> {
                        Customer customer = new Customer();
                        customer.setId(exchange.getIn().getHeader("id", 
Integer.class));
                        customer.setFirstName("Kermit");
                        customer.setLastName("The Frog");
                        exchange.getOut().setBody(customer);
                    })
                .endRest();

{code}
 

we see a swagger definition generated like this

 
{code:java}
 "paths" : {
    "/customers/\{id}" : {
      "get" : {
        "tags" : [ "customers" ],
        "summary" : "Retrieves a customer for the specified id",
        "operationId" : "route2",
        "parameters" : [ {
          "name" : "id",
          "in" : "path",
          "required" : true,
          "type" : "string"
        } ],
        "responses" : {
          "200" : {
            "description" : "Output type",
            "schema" : {
              "$ref" : "#/definitions/Customer",
              "originalRef" : "Customer"
            },
            "responseSchema" : {
              "$ref" : "#/definitions/Customer",
              "originalRef" : "Customer"
            }
          }
        }
      }
    }
  },

{code}
 

The operationId seems to be incorrect.

 

In our testsuite, which checks the latest Camel HEAD every Monday, we see ...

 
{code:java}
Caused by: java.lang.IllegalArgumentException: The specified operation with ID: 
`getCustomerById` cannot be found in the Swagger specification loaded from 
`http://localhost:8080/api/swagger`. Operations defined in the specification 
are: route2
    at 
org.apache.camel.component.rest.swagger.RestSwaggerEndpoint.createProducer(RestSwaggerEndpoint.java:198)
    at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:573)
    ... 190 more

{code}

  was:
With this code

 

{code}

        rest("/customers").description("Customers REST service")
            .get("/\{id}")
                .bindingMode(RestBindingMode.auto)
                .id("getCustomerById")
                .description("Retrieves a customer for the specified id")
                .outType(Customer.class)
                .route()
                    .process(exchange -> {
                        Customer customer = new Customer();
                        customer.setId(exchange.getIn().getHeader("id", 
Integer.class));
                        customer.setFirstName("Kermit");
                        customer.setLastName("The Frog");
                        exchange.getOut().setBody(customer);
                    })
                .endRest();

{code}

 

we see a swagger definition generated like this

 

{code}

 "paths" : {
    "/customers/\{id}" : {
      "get" : {
        "tags" : [ "customers" ],
        "summary" : "Retrieves a customer for the specified id",
        "operationId" : "route2",
        "parameters" : [ {
          "name" : "id",
          "in" : "path",
          "required" : true,
          "type" : "string"
        } ],
        "responses" : {
          "200" : {
            "description" : "Output type",
            "schema" : {
              "$ref" : "#/definitions/Customer",
              "originalRef" : "Customer"
            },
            "responseSchema" : {
              "$ref" : "#/definitions/Customer",
              "originalRef" : "Customer"
            }
          }
        }
      }
    }
  },

{code}

 

The operation seems to be incorrect.

 

In our testsuite, which checks the latest Camel HEAD every Monday, we see ...

 

{code}

Caused by: java.lang.IllegalArgumentException: The specified operation with ID: 
`getCustomerById` cannot be found in the Swagger specification loaded from 
`http://localhost:8080/api/swagger`. Operations defined in the specification 
are: route2
    at 
org.apache.camel.component.rest.swagger.RestSwaggerEndpoint.createProducer(RestSwaggerEndpoint.java:198)
    at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:573)
    ... 190 more

{code}


> Rest DSL generates invalid swagger operation Id
> -----------------------------------------------
>
>                 Key: CAMEL-12943
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12943
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-swagger
>            Reporter: Thomas Diesler
>            Priority: Major
>             Fix For: 2.23.0
>
>
> With this code
>  
> {code:java}
>         rest("/customers").description("Customers REST service")
>             .get("/\{id}")
>                 .bindingMode(RestBindingMode.auto)
>                 .id("getCustomerById")
>                 .description("Retrieves a customer for the specified id")
>                 .outType(Customer.class)
>                 .route()
>                     .process(exchange -> {
>                         Customer customer = new Customer();
>                         customer.setId(exchange.getIn().getHeader("id", 
> Integer.class));
>                         customer.setFirstName("Kermit");
>                         customer.setLastName("The Frog");
>                         exchange.getOut().setBody(customer);
>                     })
>                 .endRest();
> {code}
>  
> we see a swagger definition generated like this
>  
> {code:java}
>  "paths" : {
>     "/customers/\{id}" : {
>       "get" : {
>         "tags" : [ "customers" ],
>         "summary" : "Retrieves a customer for the specified id",
>         "operationId" : "route2",
>         "parameters" : [ {
>           "name" : "id",
>           "in" : "path",
>           "required" : true,
>           "type" : "string"
>         } ],
>         "responses" : {
>           "200" : {
>             "description" : "Output type",
>             "schema" : {
>               "$ref" : "#/definitions/Customer",
>               "originalRef" : "Customer"
>             },
>             "responseSchema" : {
>               "$ref" : "#/definitions/Customer",
>               "originalRef" : "Customer"
>             }
>           }
>         }
>       }
>     }
>   },
> {code}
>  
> The operationId seems to be incorrect.
>  
> In our testsuite, which checks the latest Camel HEAD every Monday, we see ...
>  
> {code:java}
> Caused by: java.lang.IllegalArgumentException: The specified operation with 
> ID: `getCustomerById` cannot be found in the Swagger specification loaded 
> from `http://localhost:8080/api/swagger`. Operations defined in the 
> specification are: route2
>     at 
> org.apache.camel.component.rest.swagger.RestSwaggerEndpoint.createProducer(RestSwaggerEndpoint.java:198)
>     at 
> org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:573)
>     ... 190 more
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to