3

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",
    }
}],
1

3 Answers 3

5

Change this code: "in": "query"

Sign up to request clarification or add additional context in comments.

Comments

4

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.

1 Comment

Great! If this answer helped you, consider marking it as an accepted answer to help the future visitors.
2

Example for passing query parameter through JSON:

URL : reset/[email protected]

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

1 Comment

in: path means a path parameter, as in /reset/password/[email protected], not a query parameter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.