You mean the “included” JSON you are showing is a payload sent back to the caller?
JSON References are stand-alone—they cannot have siblings. So you’ll have to do something a bit different. * Define a model as the intersection of the two objects, People and Comments. The shared components seem to be “type” and “id” * Define your response to be an Array of that common model * Extend the common model for People and Comments using the allOf construct, optionally use a discriminator to define how you know which object is a “People” and which is a “Comment”. The other approach is to define a single object and add the “attributes” as a map, like such: attributes: type: object additionalProperties: true > On Sep 8, 2016, at 8:18 AM, Duggie <[email protected]> wrote: > > Hi there, > > I want to represent an openapi-spec API in the Swagger editor. I'm struggling > to represent the "included" array in a compound document. > > So, let's say I want to define the following JSON snippet in YAML: > > ```json > "included": [ > { > "type": "people", > "id": "9", > "attributes": { > "first-name": "Dan", > "last-name": "Gebhardt", > "twitter": "dgeb" > }, > "links": { > "self": "http://example.com/people/9" > } > }, { > "type": "comments", > "id": "5", > "attributes": { > "body": "First!" > } > } > ] > ``` > > I can define the first object (people) OK, but I don't know how to define the > "comments" object. > > I have tried defining them separately and then listing them but it errors out > when I add more than one definition to `items` i.e. > > ```yaml > included: > type: array > items: > $ref: '#/definitions/people' > $ref: '#/definitions/comments' > ``` > > If I just have the "people" definition, it's fine. > > So, how should I represent an array of different objects? > > Thanks, > > Duggie > > -- > 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 [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
