Swagger array of objects

前端 未结 1 1158
说谎
说谎 2021-01-26 06:19

I am having some issues with swagger: I have an array of objects (address) described in this way in the .yaml file:

Address:
  properties:
    street:
      type         


        
相关标签:
1条回答
  • 2021-01-26 07:15

    To send JSON data, you need to use use an in: body parameter (not in: formData) and specify that the operation consumes application/json. formData parameters are used for operations that consume application/x-www-form-urlencoded or multipart/form-data.

    paths:
      /something:
         post:
           consumes:
             - application/json
           parameters:
             - in: body
               name: addresses
               required: true
               schema:
                 type: array
                 items:
                   $ref: "#/definitions/Address"  # if "Address" is in the same file
                   # or
                   # $ref: "anotherfile.yaml#/definitions/Address"  # if "Address" is in another file
    
    0 讨论(0)
提交回复
热议问题