Swagger 如何在Express/Node中通过招摇过市将参数传递到req.body中?
上面可以看到我的swagger.json路由(作为我的代码示例)。我需要了解如何在req.body中发送值(使用swagger)。我看到我们可以在Swagger 如何在Express/Node中通过招摇过市将参数传递到req.body中?,swagger,Swagger,上面可以看到我的swagger.json路由(作为我的代码示例)。我需要了解如何在req.body中发送值(使用swagger)。我看到我们可以在路径中传递参数(直接在link中传递,也可以在cookie中传递,也可以在标题中传递,以及在查询中传递) 我需要帮助创建此对象,以便以下一种方式获取参数email(req.body.email)。如何制作?如果您使用的是OpenAPI 2.0: { "in": "query", "nam
路径中传递参数(直接在link中传递,也可以在cookie中传递,也可以在标题中传递,以及在查询中传递)
我需要帮助创建此对象,以便以下一种方式获取参数email(req.body.email
)。如何制作?如果您使用的是OpenAPI 2.0:
{
"in": "query",
"name": "email",
"description": "You should pass here email",
"required": true,
"schema": {
"type": "string"
}
}
资料来源:elyas bhy帮了我很多。我会给你更多关于这个答案的信息
{
"in": "body",
"name": "body",
"description": "Resource payload",
"required": true,
"schema": {
"type": "object",
"properties": {
"email": {
"type": "string"
}
},
"required": ["email"]
}
}
它看起来像这样:
我不能给你+1 m,因为我没有这方面的许可,但我希望有人能给你+1 m)你可以自己做,发布问题后有15分钟的延迟,你才能接受答案,你现在可以再试一次。我的声誉低于15(这就是我不能的原因)你可能无法对答案进行投票,但你至少可以接受这个答案,以便将问题标记为已解决:)如果我没有弄错的话,这也会增加你的声誉。你想使用“``”围绕您的代码,使格式更好。另外,请更准确地解释你发布的是什么,您好,欢迎来到SO!虽然这段代码可以回答这个问题,但提供关于它如何和/或为什么解决问题的附加上下文将提高答案的长期价值。请阅读,然后
"parameters": [
{
"in": "body",
"name": "body",
"description": "You should pass here email",
"required": true,
"schema": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"password": {
"type": "string"
}
}
}
}
],
"parameters": [
{
"in": "body",
"name": "body",
"description": "You should pass here email",
"required": true,
"schema": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"password": {
"type": "string"
}
}
}
}
],
/**
* @swagger
* produces:
* - "application/xml"
* - "application/json"
* parameters:
* - name: level_id
* in: path
* required: true
* - name: body
* description: Please enter an email here
* in: body
* required: true
* schema:
* $ref: '#/definitions/levels'
* responses:
* 201:
* description: updated
* 404:
* description: Not found
* 500:
* description: Internal Server error
*/