2
votes

I am trying to pass query parameters from request URL in NodeJS swagger.json. But I am getting undefined.

here is the URL reset/[email protected]

On NodeJS swagger "parameters": [ { "name": "Parameters", "in": "",
"required": true, "type": "string", "schema": { "$ref": "#/definitions/resetPassword", } } ],

3

3 Answers

3
votes

Example for passing query parameter through JSON:

URL : reset/[email protected]

parameters:
        - in: path
          name: email
          type: string
          required: true
          description: description of parameter
2
votes

Change this code: "in": "query"

1
votes

Your parameter definition should look like this:

"parameters": [
    {
      "name": "email",
      "in": "query",
      "type": "string",
      "format": "email",
      "required": true
    }
  ]

in: query indicates that the parameter is passed in the query string.

name: ... is the parameter name (in your example - email).

type: string and format: email indicate the parameter type. Query parameters require a primitive type (string, number, etc.) or an array type, but they cannot $ref definitions. format is an optional hint for tools that will process your OpenAPI definition.

Check out the Describing Parameters guide for more details.