Swagger UI - 正文中的多个参数覆盖最后一个变量值

Swagger UI - Multiple parameters in body overrides last variable value

我的身份验证路径有以下文档:

目前正在通过此生成 JSON:

"post": {
        "description": "Authenticate an user",
        "tags": [
            "session"
        ],
        "consumes": "application/json",
        "parameters": [
            {
                "name": "email",
                "in": "body",
                "description": "user email",
                "required": true,
                "schema": {
                    "type": "string"
                }
            },
            {
                "name": "password",
                "in": "body",
                "description": "user password",
                "required": true,
                "schema": {
                    "type": "string"
                }
            }
        ],

问题是,当我尝试使用 Try it out! 功能并使用正确的值填充电子邮件和密码字段并执行请求时,我的浏览器正在发送此请求:

如您所见,它只是发送密码,而实际上应该发送:{"email": "gustavo-olegario@hotmail.com", "password": "12345678"}。 为什么会这样?是 JSON 文件中的配置错误吗?

我不确定你的问题...

如果您试图为一项操作定义多个 body 参数,则不能。如 swagger 规范中所述:

Body [...] there can only be one body parameter

如果您尝试发送带有多个参数的 body,请在定义部分添加一个 object 模型并在您的 body 参数中引用它。

更多详情: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameter-object

编辑:

为了更加安全,请将密码发送至 header 属性。