Uploaded image for project: 'Red Hat Build of Apache Camel for Quarkus'
  1. Red Hat Build of Apache Camel for Quarkus
  2. CEQ-11203

camel-rest: Contract first implementation doesn't honor the contextPath set in restConfiguration

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False
    • 0
    • +

      The implementation of the OpenAPI contract doesn't work with camel quarkus if the contextPath is set in the restConfiguration.

       restConfiguration()
                      .apiContextPath("/api/openapi")
                      .contextPath("/camel")
                      .hostNameResolver(RestHostNameResolver.none);
      
              rest("/camel")
                      .openApi()
                      .specification("openapi/contract.json");
      
              from("direct:fetchMessage")
                      .routeId(ROUTE_ID)
                      .autoStartup(enabled)
                      .log("Request Received...")
                      .setBody().constant("Success");
      

      Contract:

      {
        "openapi": "3.0.1",
        "info": {
          "title": "Test API",
          "version": "1.0.0",
          "description": "NA"
        },
        "paths": {
          "/fetch": {
            "get": {
              "tags": [
                "fetch"
              ],
              "summary": "fetch Message",
              "operationId": "fetchMessage",
              "description": "NA",
              "requestBody": {
                "required": false
              },
              "responses": {
                "200": {
                  "description": "Message successfully fetch from the queue.",
                  "content": {
                    "application/json": {
                      "schema": {
                        "type": "string"
      }}}}}}}}}
      

      Now if you run: http://localhost:8080/camel/api/openapi

      It generates:

      
        "servers" : [ {
          "url" : "/"
        } ],
      
      

      Now, accessing http://localhost:8080/camel/fetch gives 404

      If we remove the .contextPath("/camel") from the restConfiguration, it works but now, it registers the API endpoint on the root ("/") context:

      http://localhost:8080/fetch

              jondruse@redhat.com Jiri Ondrusek
              rhn-support-adongre Avinash Dongre
              Lukas Lowinger Lukas Lowinger
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: