Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-10925

camel rest && swagger does not works correctly on SB2

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • fuse-7.5-ER1
    • fuse-7.4-GA
    • Camel
    • None
    • Fuse 7.5 Sprint 50 - Dev #1

    Description

      I am creating REST API using camel-rest DSL. I am using camel-swagger-java for creating swagger.json file. Basicly my route seems like this

      rest().path("/user").produces("text/plain")
      				.get("/{id}").id("myOperation")
      				.param().type(RestParamType.path).name("id").endParam()
      				.to("direct:getId")
      				.get("/{id}/user").id("getId/user")
      				.param().type(RestParamType.path).name("id").endParam()
      				.to("direct:getId");
      

      Let's do a few experiments:
      1) start attached reproducer with this command:

      mvn clean install -Psb1 && mvn spring-boot:run -Psb1
      

      This command will start application with

      <dependency>
      	<groupId>org.jboss.redhat-fuse</groupId>
      	<artifactId>fuse-springboot-bom</artifactId>
      	<version>7.4.0.fuse-740031-redhat-00001</version>
      	<type>pom</type>
      	<scope>import</scope>
      </dependency>
      

      A.K.A Fuse 7.4 on spring-boot-1.
      2) open http://localhost:8080/swagger.json
      3) you will see

      {
        "swagger" : "2.0",
        "info" : {
          "version" : "1.0",
          "title" : "Rest swagger"
        },
        "host" : "localhost:8080",
        "basePath" : "/",
        "tags" : [ {
          "name" : "user"
        } ],
        "schemes" : [ "http" ],
        "paths" : {
          "/user/{id}" : {
            "get" : {
              "tags" : [ "user" ],
              "operationId" : "myOperation",
              "produces" : [ "text/plain" ],
              "parameters" : [ {
                "name" : "id",
                "in" : "path",
                "required" : true,
                "type" : "string"
              } ],
              "responses" : {
                "200" : { }
              }
            }
          },
          "/user/{id}/user" : {
            "get" : {
              "tags" : [ "user" ],
              "operationId" : "getId/user",
              "produces" : [ "text/plain" ],
              "parameters" : [ {
                "name" : "id",
                "in" : "path",
                "required" : true,
                "type" : "string"
              } ],
              "responses" : {
                "200" : { }
              }
            }
          }
        }
      }
      

      . Focus on {{operationId}}s This is correct and expected output.

      4) Now let's start our application with Fuse 7.4 on spring-boot-2.

      mvn clean install  && mvn spring-boot:run 
      

      5) visit http://localhost:8080/swagger.json

      {
        "swagger" : "2.0",
        "info" : {
          "version" : "1.0",
          "title" : "Rest swagger"
        },
        "host" : "localhost:8080",
        "basePath" : "/",
        "tags" : [ {
          "name" : "user"
        } ],
        "schemes" : [ "http" ],
        "paths" : {
          "/user/{id}" : {
            "get" : {
              "tags" : [ "user" ],
              "operationId" : "route2",
              "produces" : [ "text/plain" ],
              "parameters" : [ {
                "name" : "id",
                "in" : "path",
                "required" : true,
                "type" : "string"
              } ],
              "responses" : {
                "200" : { }
              }
            }
          },
          "/user/{id}/user" : {
            "get" : {
              "tags" : [ "user" ],
              "produces" : [ "text/plain" ],
              "parameters" : [ {
                "name" : "id",
                "in" : "path",
                "required" : true,
                "type" : "string"
              } ],
              "responses" : {
                "200" : { }
              }
            }
          }
        }
      }
      

      Focus again on operationId. First is incorrect and second is missing.

      Lets do our final experiment.
      6) change our REST to

      rest().path("/user").produces("text/plain")
      				.get("/{id}").id("myOperation")
      				.param().type(RestParamType.path).name("id").endParam()
      				.to("direct:getId");
      

      - remove one endpoint.
      7)

      {
        "swagger" : "2.0",
        "info" : {
          "version" : "1.0",
          "title" : "Rest swagger"
        },
        "host" : "localhost:8080",
        "basePath" : "/",
        "tags" : [ {
          "name" : "user"
        } ],
        "schemes" : [ "http" ],
        "paths" : {
          "/user/{id}" : {
            "get" : {
              "tags" : [ "user" ],
              "operationId" : "myOperation",
              "produces" : [ "text/plain" ],
              "parameters" : [ {
                "name" : "id",
                "in" : "path",
                "required" : true,
                "type" : "string"
              } ],
              "responses" : {
                "200" : { }
              }
            }
          }
        }
      }
      

      - operationId is correct.

      Attachments

        Activity

          People

            yfang@redhat.com Freeman(Yue) Fang
            jbouska@redhat.com Jan Bouska
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: