Swagger UI parameters not working in try it now

27 views
Skip to first unread message

r...@graphyte.ai

unread,
Jun 21, 2018, 7:12:42 AM6/21/18
to Swagger
Hi,

I have embedded Swagger UI into my own React app using the npm module using the api config from a swagger hub url. This works fine and allows me to browse the api and even try out methods that don't require parameters.

However whenever I try and use path (or query) parameters with Try it now I hit a strange problem where the required parameter (there is only one for my api) is not recognised as being entered in the input box and I get a validation error and the API doesn't run. If I set a default it will work but is passing the default value through to the execution rather than what I enter in the parameter value box.

Here is a sample of the Swagger definition for the API showing the parameter that I'm trying to get to work:

  /methods/{methodKey}:
    get:
      parameters:
      - name: "methodKey"
        in: "path"
        required: true
        type: "string"
      consumes:
      - "application/json"
      produces:
      - "application/json"
      responses:
        200:
          description: "200 response"
          schema:
            $ref: "#/definitions/Empty"
          headers:
            Access-Control-Allow-Origin:
              type: "string"
      x-amazon-apigateway-integration:
        responses:
          default:
            statusCode: "200"
            responseParameters:
              method.response.header.Access-Control-Allow-Origin: "'*'"
            responseTemplates:
              application/json: "$input.json(\"$.hits.hits[0]['_source']\")"
        requestParameters:
          integration.request.path.methodKey: "method.request.path.methodKey"
        requestTemplates:
          application/json: "{\"query\": {\"bool\":{ \"must\": [{\"match\": {\"_id\"\
            : \"$input.params('methodKey')\"}}]}}}"
        passthroughBehavior: "when_no_templates"
        httpMethod: "POST"
        type: "http"

Any help would be much appreciated.

Thanks,
Rob
Reply all
Reply to author
Forward
0 new messages