cancel
Showing results for 
Search instead for 
Did you mean: 

Examples in a component - Array of objects

Occasional Contributor

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?

2 REPLIES 2
Highlighted
Community Leader

Re: Examples in a component - Array of objects

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?

Highlighted
Occasional Contributor

Re: Examples in a component - Array of objects

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