Forum Discussion

mcrobbj's avatar
mcrobbj
Occasional Contributor
6 years ago

Examples in a component - Array of objects

I have a nested component that I want to have examples of

 

So

 

components:
  schema:
    myObject:
      type: object
      properties:
        authId:
          type: string
        myArray:
          type: array
          items:
            $ref: '#/components/schemas/myObject2'

    myObject2:
      type: object
      properties:
        filed1:
          type: string
        filed2:
          type: string

 

and an example like:

{ authId: "123",
  [ { field1: "One",
      filed2: "two"},
{ field1: "three",
      filed2: "four"},
] }

How do I do this?

  • Wamboo's avatar
    Wamboo
    Community Hero

    I'm sorry, but I don't understand exactly what you mean by this post.

     

    Do you want to learn how to dynamically create objects in JS from the presented data?

    • mcrobbj's avatar
      mcrobbj
      Occasional Contributor

      No I want to define the swagger with examples, so I have defined an object with an array of objects just want to be able to add examples, like I give the JSON for