简体   繁体   中英

How to create a Json object from the Schema definitions of swagger

I am failing to to remove the outer array from the json request body that I want swagger to generate from the schema definitions.

I want to generate this object:

{
    "name": 
    { 
        "value": "test04" 

    },
    "mail": { 
        "value": "test04@gmail.com" 
    }
}

But swagger is giving me this:

[
  {
    "name": {
      "value": "string"
    },
    "mail": {
      "value": "string"
    }
  }
]

This is my definition section:

definitions:
  user:
    type: "object"
    properties:
       name: 
        type: object
        properties: 
          value: 
            type: string
       mail: 
        type: object
        properties: 
          value: 
            type: string

May you kindly assist. I am new to swagger. I am using version 2.0

您的User架构是正确的,因此这意味着还有一个额外的type: array使用该架构的参数,请求正文或响应中某处的type: array

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM