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

camel-openapi-java - Operation paths are incorrect if contextPath is set

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.13.0, 3.14.0
    • 3.15.0
    • camel-openapi-java
    • None
    • Unknown

    Description

      Consider this REST configuration:

      restConfiguration()
          .host("localhost")
          .apiHost("localhost")
          .contextPath("/api")
          .port(8080)
          .apiContextPath("/api-docs");
      
      
      rest("/service")
          .get("/testing").description("Test Service")
          .outType(String.class)
          .route().setBody().constant("Hello World");
      

      The 'paths' object in the generated OpenAPI document is incorrect. It should not have the '/api' context path prefix.

      {
        "openapi" : "3.0.2",
        "info" : { },
        "servers" : [ {
          "url" : "/api"
        } ],
        "paths" : {
          "/api/service/testing" : {
            "get" : {
              "tags" : [ "/service" ],
              "responses" : {
                "200" : { }
              },
              "operationId" : "verb1",
              "summary" : "Test Service"
            }
          }
        },
        "components" : { },
        "tags" : [ {
          "name" : "/service"
        } ]
      }
      

      The OpenAPI spec states:

      "Unless specified otherwise, all properties that are URLs MAY be relative references as defined by RFC3986. Relative references are resolved using the URLs defined in the Server Object as a Base URI.".

      If you try to execute the service in the Swagger UI, then it tries to hit http://localhost:8080/api/api/service/testing (duplicate /api/api in the path).

      Maybe the code we had before CAMEL-17063 was implemented was more correct?

      Attachments

        Issue Links

          Activity

            People

              klease78 Karen Lease
              jamesnetherton James Netherton
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: