0

当我尝试访问 requestBody 时,它给了我错误无法访问未定义。
然后我通过打印req.swagger.params进行检查,它看起来像这样:

  { _id: 
     { path: '/v0/users/config/{_id}',
       schema: [Object],
       originalValue: '123',
       value: '123' },
    undefined: 
     { path: '/v0/users/config/{_id}',
       schema: [Object],
       originalValue: [Object],
       value: [Object] } }

无法理解 requestBody 出现未定义键名的原因。

我现在如何访问 requestBody?

4

1 回答 1

2

我找到了为面临相同问题的其他人发布解决方案的解决方案。它的文档中没有提到它。

requestBody:
  x-name: body 
  content:
    application/json:
      schema:
        required:
        - name
        properties:
          name:
            type: array
            items:
              type: string
            description: Updated name of the pet
          status:
            type: string
            description: Updated status of the pet

我们必须在x-name中提及 requestBody的名称

于 2020-02-07T08:51:50.537 回答