Swagger用户界面-主体中的多个参数覆盖最后一个变量值

5gfr0r5j  于 2022-11-06  发布在  其他
关注(0)|答案(1)|浏览(141)

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

当前正在通过此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文件上的配置缺失吗?

2izufjch

2izufjch1#

我不太明白你的问题...
如果您尝试为一个操作定义多个几何体参数,则不能这样做。如swagger规范中所述:

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

如果您尝试传送具有多个参数的主体,请在定义区段中加入对象模型,并在主体参数中指涉它。
如需详细信息:https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#parameter-object

相关问题