Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-12943

Rest DSL generates invalid swagger operation Id

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.23.0
    • Component/s: camel-swagger
    • Labels:
      None
    • Estimated Complexity:
      Unknown

      Description

      With this 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();
      
      

       

      we see a swagger definition generated like this

       

       "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"
                  }
                }
              }
            }
          }
        },
      
      

       

      The operationId seems to be incorrect.

       

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

       

      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
      
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dmvolod Dmitry Volodin
                Reporter:
                tdiesler Thomas Diesler
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: