DEV Community

Gustavo Silva
Gustavo Silva

Posted on

[Swagger] How do I return an array of objects with 3 differents objects?

I need to get a response like this

[

   {

      "objProp1": First object inside the response body

    },

   {

      "objProp2": Second object inside the response body

    },

   {

      "objProp3": Third object inside the response body

    }

]
Enter fullscreen mode Exit fullscreen mode

And I'm setting up the yaml file like this:

Request/Response:

  type: array

  items:

    Object1:

       type: object

       properties:

         objProp1: string

    Object2:

       type: object

       properties:

         objProp2: string

    Object3:

       type: object

       properties:

         objProp3: string

   example: []
Enter fullscreen mode Exit fullscreen mode

But when I open the swagger.. both request body and response body are showing this:

[

  "string"

]
Enter fullscreen mode Exit fullscreen mode

what am I doing wrong? please help 😥

Top comments (0)