打开 API 3.0 RequestBody 在 req.swagger.params 中无法访问,因为它在节点 API 中未定义

Open API 3.0 RequestBody not accessible in req.swagger.params as it is coming in undefined in node API

当我尝试访问 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?

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

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的名称