Uploaded image for project: 'Red Hat 3scale API Management'
  1. Red Hat 3scale API Management
  2. THREESCALE-6655

ActiveDocs: servers element is appended to API response

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Obsolete
    • Icon: Major Major
    • None
    • 2.9.1 GA
    • System
    • False
    • False
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Undefined
    • Hide

      Environment:

      • 3scale 2.9 installed on OpenShift 4.6 using the 3scale operator v0.6.1.
      • 3scale installed with a single tenant

      To reproduce:

      • In 3scale admin portal for the tenant, add CORS policy to API Product. Promote to staging and production APIcast.
      • Navigate to Product:API -> ActiveDocs
      • Test GET Endpoint
        Expected response:
        {
          "method": "GET",
          "path": "/",
          "args": "user_key=afd59d201ea15ac4caf757bbe9dd6a45",
          "body": "",
          "headers": {
            "HTTP_VERSION": "HTTP/1.1",
            "HTTP_HOST": "echo-api.3scale.net",
            "HTTP_ACCEPT": "application/json",
            "HTTP_ACCEPT_ENCODING": "gzip, deflate, br",
            "HTTP_ACCEPT_LANGUAGE": "en,en-US;q=0.5",
            "HTTP_DNT": "1",
            "HTTP_ORIGIN": "https://user1-3scale-admin.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com",
            "HTTP_REFERER": "https://user1-3scale-admin.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com/",
            "HTTP_USER_AGENT": "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0",
            "HTTP_X_3SCALE_PROXY_SECRET_TOKEN": "Shared_secret_sent_from_proxy_to_API_backend_d89486900bbaaeef",
            "HTTP_X_REAL_IP": "10.128.2.9",
            "HTTP_X_FORWARDED_FOR": "178.119.47.150, 52.49.73.94, 10.0.101.168",
            "HTTP_X_FORWARDED_HOST": "echo-api.3scale.net",
            "HTTP_X_FORWARDED_PORT": "443",
            "HTTP_X_FORWARDED_PROTO": "https",
            "HTTP_FORWARDED": "for=10.0.101.168;host=echo-api.3scale.net;proto=https"
          },
          "uuid": "66bac8ae-e8f0-403c-93c3-a56c1fbe7eb0"
        }
        

        See screenshots 3scale1-1.png and 3scale2.png

      • Deploy the 'quay.io/gpte3scale/echo-api:latest' image on the OpenShift. The only difference between this image and the hosted endpoint at https://echo-api.3scale.net/ is that this image returns "requestmethod": "GET" instead of "method": "GET".
        To deploy the image:
        oc new-project echo
        oc new-app --name=echo --docker-image=quay.io/gpte3scale/echo-api:latest -n echo
        
      • Change the private base URL of the API Backend to point to the the echo app on OpenShift. Set the URL to http://echo.echo.svc:9292. Promote to staging and production APIcast.
      • Repeat the ActiveDocs test.
        Response:
        {
          "requestmethod": "GET",
          "path": "/",
          "args": "user_key=afd59d201ea15ac4caf757bbe9dd6a45",
          "body": "",
          "headers": {
            "HTTP_VERSION": "HTTP/1.1",
            "HTTP_X_REAL_IP": "10.128.2.9",
            "HTTP_HOST": "echo.echo.svc:9292",
            "HTTP_X_3SCALE_PROXY_SECRET_TOKEN": "Shared_secret_sent_from_proxy_to_API_backend_d89486900bbaaeef",
            "HTTP_USER_AGENT": "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0",
            "HTTP_ACCEPT": "application/json",
            "HTTP_ACCEPT_LANGUAGE": "en,en-US;q=0.5",
            "HTTP_ACCEPT_ENCODING": "gzip, deflate, br",
            "HTTP_REFERER": "https://user1-3scale-admin.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com/",
            "HTTP_ORIGIN": "https://user1-3scale-admin.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com",
            "HTTP_DNT": "1",
            "HTTP_X_FORWARDED_HOST": "api-user1-3scale-apicast-production.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com",
            "HTTP_X_FORWARDED_PORT": "443",
            "HTTP_X_FORWARDED_PROTO": "https",
            "HTTP_FORWARDED": "for=178.119.47.150;host=api-user1-3scale-apicast-production.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com;proto=https",
            "HTTP_X_FORWARDED_FOR": "178.119.47.150"
          },
          "uuid": "de799155-cef2-4a2a-8a0b-711752050f36",
          "servers": [
            {
              "url": "https://api-user1-3scale-apicast-production.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com:443"
            }
          ]
        }
        

        Note the additional servers element added to the end of the response body.
        See screenshots 3scale3.png and 3scale4.png

      • Note the following error in the browser console:
        TypeError: can't convert undefined to object
            injectAutocompleteToResponseBody OAS3Autocomplete.js:3
            _callee$/< OAS3Autocomplete.js:87
            promise callback*_callee$ OAS3Autocomplete.js:87
            Babel 8
            responseInterceptor service_active_docs.js:1
            _callee$ index.js:884
            Babel 15
            makeHttp index.js:1202
            execute index.js:4791
            Le swagger-ui.js:1335
            G swagger-ui.js:243
            bindActionCreator Redux
            s swagger-ui.js:5058
            r swagger-ui.js:13702
            B swagger-ui.js:13887
            De swagger-ui.js:1361
            G swagger-ui.js:243
            bindActionCreator Redux
            y swagger-ui.js:5441
            r swagger-ui.js:13702
            B swagger-ui.js:13887
            t swagger-ui.js:16747
            React 14
        

        See screenshot 3scale5.png

      Note the following code in OAS3Autocomplete.js:87:

      // response.body.method is not present when fetching the spec,
      // is present when doing a request to one of the paths
      const isSpecFetched = (response: SwaggerResponse): boolean => !!response.body.method
      

      This seems to indicate that a field method is expected in response.body

      Show
      Environment: 3scale 2.9 installed on OpenShift 4.6 using the 3scale operator v0.6.1. 3scale installed with a single tenant To reproduce: In 3scale admin portal for the tenant, add CORS policy to API Product. Promote to staging and production APIcast. Navigate to Product:API -> ActiveDocs Test GET Endpoint Expected response: { "method" : "GET" , "path" : "/" , "args" : "user_key=afd59d201ea15ac4caf757bbe9dd6a45" , "body" : "", "headers" : { "HTTP_VERSION" : "HTTP/1.1" , "HTTP_HOST" : "echo-api.3scale.net" , "HTTP_ACCEPT" : "application/json" , "HTTP_ACCEPT_ENCODING" : "gzip, deflate, br" , "HTTP_ACCEPT_LANGUAGE" : "en,en-US;q=0.5" , "HTTP_DNT" : "1" , "HTTP_ORIGIN" : "https: //user1-3scale-admin.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com" , "HTTP_REFERER" : "https: //user1-3scale-admin.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com/" , "HTTP_USER_AGENT" : "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0" , "HTTP_X_3SCALE_PROXY_SECRET_TOKEN" : "Shared_secret_sent_from_proxy_to_API_backend_d89486900bbaaeef" , "HTTP_X_REAL_IP" : "10.128.2.9" , "HTTP_X_FORWARDED_FOR" : "178.119.47.150, 52.49.73.94, 10.0.101.168" , "HTTP_X_FORWARDED_HOST" : "echo-api.3scale.net" , "HTTP_X_FORWARDED_PORT" : "443" , "HTTP_X_FORWARDED_PROTO" : "https" , "HTTP_FORWARDED" : " for =10.0.101.168;host=echo-api.3scale.net;proto=https" }, "uuid" : "66bac8ae-e8f0-403c-93c3-a56c1fbe7eb0" } See screenshots 3scale1-1.png and 3scale2.png Deploy the 'quay.io/gpte3scale/echo-api:latest' image on the OpenShift. The only difference between this image and the hosted endpoint at https://echo-api.3scale.net/ is that this image returns "requestmethod": "GET" instead of "method": "GET" . To deploy the image: oc new -project echo oc new -app --name=echo --docker-image=quay.io/gpte3scale/echo-api:latest -n echo Change the private base URL of the API Backend to point to the the echo app on OpenShift. Set the URL to http://echo.echo.svc:9292 . Promote to staging and production APIcast. Repeat the ActiveDocs test. Response: { "requestmethod" : "GET" , "path" : "/" , "args" : "user_key=afd59d201ea15ac4caf757bbe9dd6a45" , "body" : "", "headers" : { "HTTP_VERSION" : "HTTP/1.1" , "HTTP_X_REAL_IP" : "10.128.2.9" , "HTTP_HOST" : "echo.echo.svc:9292" , "HTTP_X_3SCALE_PROXY_SECRET_TOKEN" : "Shared_secret_sent_from_proxy_to_API_backend_d89486900bbaaeef" , "HTTP_USER_AGENT" : "Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0" , "HTTP_ACCEPT" : "application/json" , "HTTP_ACCEPT_LANGUAGE" : "en,en-US;q=0.5" , "HTTP_ACCEPT_ENCODING" : "gzip, deflate, br" , "HTTP_REFERER" : "https: //user1-3scale-admin.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com/" , "HTTP_ORIGIN" : "https: //user1-3scale-admin.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com" , "HTTP_DNT" : "1" , "HTTP_X_FORWARDED_HOST" : "api-user1-3scale-apicast-production.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com" , "HTTP_X_FORWARDED_PORT" : "443" , "HTTP_X_FORWARDED_PROTO" : "https" , "HTTP_FORWARDED" : " for =178.119.47.150;host=api-user1-3scale-apicast-production.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com;proto=https" , "HTTP_X_FORWARDED_FOR" : "178.119.47.150" }, "uuid" : "de799155-cef2-4a2a-8a0b-711752050f36" , "servers" : [ { "url" : "https: //api-user1-3scale-apicast-production.apps.cluster-7bd8.7bd8.sandbox464.opentlc.com:443" } ] } Note the additional servers element added to the end of the response body. See screenshots 3scale3.png and 3scale4.png Note the following error in the browser console: TypeError: can't convert undefined to object injectAutocompleteToResponseBody OAS3Autocomplete.js:3 _callee$/< OAS3Autocomplete.js:87 promise callback*_callee$ OAS3Autocomplete.js:87 Babel 8 responseInterceptor service_active_docs.js:1 _callee$ index.js:884 Babel 15 makeHttp index.js:1202 execute index.js:4791 Le swagger-ui.js:1335 G swagger-ui.js:243 bindActionCreator Redux s swagger-ui.js:5058 r swagger-ui.js:13702 B swagger-ui.js:13887 De swagger-ui.js:1361 G swagger-ui.js:243 bindActionCreator Redux y swagger-ui.js:5441 r swagger-ui.js:13702 B swagger-ui.js:13887 t swagger-ui.js:16747 React 14 See screenshot 3scale5.png Note the following code in OAS3Autocomplete.js:87 : // response.body.method is not present when fetching the spec, // is present when doing a request to one of the paths const isSpecFetched = (response: SwaggerResponse): boolean => !!response.body.method This seems to indicate that a field method is expected in response.body

      When testing an API with ActiveDocs, the API response is rewritten if the API response does not contain a field called 'method'.
      More precisely, an additional element 'servers' is appended to the response.
      The browser console shows an error in this case.

        1. 3scale1-1.png
          3scale1-1.png
          147 kB
        2. 3scale2.png
          3scale2.png
          147 kB
        3. 3scale3.png
          3scale3.png
          153 kB
        4. 3scale4.png
          3scale4.png
          150 kB
        5. 3scale5.png
          3scale5.png
          51 kB

            Unassigned Unassigned
            btison Bernard Tison
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: