Is this the correct instance example for the given OpenAPI schema?

Viewed 26

Looking for some help writing an example for OpenAPI schema components. The schemas look like this:

components:
  schemas:
    ResponseBody:
      type: object
      properties:
        order:
          type: string
        items:
          type: array
          items:
            $ref: '#/components/schemas/items'
    items:
      type: object
      properties:
        itemsNo:
          type: string
        item:
          type: array
          items:
            $ref: '#/components/schemas/item'
    item:
      type: object
      properties:
        itemNo:
          type: string
        itemName:
          type: array
          items:
            type: string
        itemDesc:
          type: array
          items:
            type: string
        itemAmount:
          type: array
          items:
            type: string

The example I came up with is something like this for the above schema:

{
  "order": "1234",
  "items": [
    {
      "itemsNo": "123",
      "item": [
        {
          "itemNo": "1",
          "itemName": [ "abc","bcs"],
          "itemDesc": [ "desc1", "desc2" ],
          "itemAmount": ["67","12"]
        }
      ]
    },
    {
      "itemsNo": "456",
      "item": [
        {
          "itemNo": "1",
          "itemName": [ "tre","jy"],
          "itemDesc": [ "desc3" ],
          "itemAmount": ["89","23"]
        },
        {
          "itemNo": "1",
          "itemName": [],
          "itemDesc": ["desc4"],
          "itemAmount": []
        }
      ]
    }
  ]
}

Can you someone please verify if it is correct? If it's not, could you please suggest some changes?

1 Answers

Yes, this JSON example matches your ResponseBody schema.

Related