Expected type array but found type object

2,346 views
Skip to first unread message

Poonam

unread,
Sep 8, 2015, 7:51:04 PM9/8/15
to Swagger

paths:
    /pathname/?gzip=false:
      post: 
        summary: "get the list of all the operators"
        description: "get list of operators"
        consumes:
          - "application/json"
        produces:
          - "application/json"
        parameters:
         in: "body"

         required: true
         schema:
           type: object
           required:
           - idcode
           - name

           properties:
            idcode:
              type: string
            name:
              type: string
 

        responses:
       
          200:
            description: "successful operation"
            schema:
              type: object
              items:
                $ref: "#/definitions/post-pathname"



above is the sample code  giving me error "expected type array but found type object
I will be providing input in json format such as idcode and name above and will get the output in json format


this is the example of curl command for which I have created swagger def above.

curl -v  -H "Content-Type: application/json" -X POST "http://.................................." -d "{\"idcode\":\"newtest\", \"name\":\"test\"}"

this is the output I will get after curl command

{
  "id": 37,
  "idcode" : "newtest",
  "name" : "test "
}

Can you let me know what can be wrong in the syntax or any suggestion how to proceed
thanks


tony tam

unread,
Sep 8, 2015, 8:12:05 PM9/8/15
to <swagger-swaggersocket@googlegroups.com>
Hi, are you talking about inside the swagger-ui?  Or is this an error from the validator?

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Poonam

unread,
Sep 8, 2015, 11:56:34 PM9/8/15
to Swagger
I am using swagger editor.

Poonam

unread,
Sep 8, 2015, 11:58:58 PM9/8/15
to Swagger
I am using swagger editor


On Tuesday, September 8, 2015 at 4:51:04 PM UTC-7, Poonam wrote:

tony tam

unread,
Sep 9, 2015, 12:48:36 AM9/9/15
to <swagger-swaggersocket@googlegroups.com>
Your spec isn't quite valid.  Use the tab-completion in the editor to guide you or read the swagger specification--specifically, your parameters object needs to contain an array of parameters.  There is also a missing `name` field:

paths: 
  /pathname: 
    post: 
      summary: "get the list of all the operators"
      description: "get list of operators"
      consumes: 
        - "application/json"
      produces: 
        - "application/json"
      parameters:
        - name: body
          in: "body"
          required: true
          schema:
            type: object
            required:
              - idcode
              - name
            properties:
              idcode:
                type: string
              name:
                type: string
Reply all
Reply to author
Forward
0 new messages