Array of objects as an input parameter in swagger

↘锁芯ラ 提交于 2019-11-29 02:40:20

If I understand correctly, your request body to post is a json object instead of form. In such case, your swagger document need to be modified as follows:

  1. When request body is json, a parameter with in: body is used instead of multiple parameters of in: formData.
  2. If in is body, a schema object is required.
  3. Defined the json properties under schema. If the property type is array, items object is required.

Following is an example:

paths:
  /bulk-action:
    post:
      consumes:
        - application/json
      parameters:
        - name: body
          in: body
          schema:
            properties:
              sources:
                type: array
                items:
                  $ref: '#/definitions/BulkSource'
              destinationdId:
                type: integer
      responses:
        200:
          description: OK
definitions:
  BulkSource:
    type: object
    properties:
      id:
        type: integer
      parentId:
        type: integer
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!