I am trying to pass query parameters from request URL in NodeJS swagger.json. But I am getting undefined.
here is the URL reset/password?email=myname@mail.com
On NodeJS swagger "parameters": [ { "name": "Parameters", "in": "",
"required": true, "type": "string", "schema": { "$ref": "#/definitions/resetPassword", } } ],
更改此代码: "in": "query"
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.
Example for passing query parameter through JSON:
URL : reset/password?email=myname@mail.com
parameters:
- in: path
name: email
type: string
required: true
description: description of parameter
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.