tendaitakas
tendaitakas

Reputation: 358

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": "[email protected]" 
    }
}

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

Upvotes: 0

Views: 468

Answers (1)

Helen
Helen

Reputation: 97540

Your User schema is correct, so this means there's an extra type: array somewhere in the parameter, request body, or response where this schema is used.

Upvotes: 2

Related Questions