如何定义一个YAML请求正文,该正文包含带有附加几个属性的对象数组?

时间:2019-10-22 13:09:59

标签: openapi

在开放式api 3.0中,我想将请求主体与另一个对象附加到数组中...................................... ................................................... ................................................... ................................................... ........

在YAML中,我这样写:

               requestBody:
                    description: this is the body
                    required: true
                    content:
                       application/json:
                       schema:
                           type: array
                           items:
                             $ref: '#/components/schemas/data'



        components:
           schemas:
             otherDetails:  
                 type : object
                 required:
                   - time_zone
                   - version
                   - module
                 properties:
                    time_zone:
                       type: string
                       example: IST
                    version:
                       type: string
                       example: 2.3.0
                    module:
                       type: string
                       example: abc
        data:
          type: object
          required:
            - name
            - description
            - expired
          properties:
             name:
                type: string
                example: dummyNode
             description:
                type: string
                example: description
             expired:
                type: string
                example: no
            otherDetails:
                $ref: '#/components/schemas/otherDetails'

但是在数组的开头/结尾以及中间出现了额外的“ [”和“]”。 输出:

      [
             {
               "data": [
                 [     ****dont want this bracket****
                   {
                     "name": "nodename1",
                     "description": "ab804529-11d0-4781-a49a-3bbbc40243df",
                     "expired": "no"
                   },
                   {
                     "name": "nodename2",
                     "description": "jlefliwajef-45f4-4322-a453-fafe3",
                     "expired": "yes"
                   }
                 ]   ****dont want this bracket****
               ],
               "time_zone": "string",
               "version": "string",
               "module": "string"
             }
         ]

有人可以帮助我获得如下所述的预期格式吗? 预期:

               {
                    "data": [
                               {
                                   "name": "nodename1",
                                   "description": "here is the description",
                                   "expired": "no"
                               },
                               {
                                    "name": "nodename2",
                                    "description": "here is the description",
                                    "expired": "yes"
                               }
                            ],
                           "time_zone": "IST",
                           "version": "2.3.0",
                           "module": "abc"
             }

0 个答案:

没有答案