1

I would like to declare array in array in swagger, but not sure how to do it: e.g. I have case, with below parameters:

       "cells": [
           [
               {
                   "field": "testID",
                   "name": "testId",
                   "width": "74px",
                   "sortable": true
               },
               {
                   "field": "test number",
                   "name": "test number name",
                   "width": "100px",
                   "sortable": true
               },
               {
                   "field": "testName",
                   "name": "testNamename",
                   "width": "200px",
                   "sortable": true
               },
           ]
       ]
   },

You can see, that JSON parameters are in array, which is in array. I would like to convert this into swagger yaml syntax. I've tried to write something like:

definitions:
  columns:
    type: object
  cells:
    type: array
    items: {
      type: array
      items: {
      properties: 
        field: 
          type: string
        name:
          type: string
        width:
          type: string
        sortable:
          type: boolean
      }
    }

But on the second items I received error message of 'missed comma between the flow collection entries'. Any ideas what it could be?

0

1 Answer 1

1

According to the swagger docs for array data types it should look like this:

definitions:
  cells:
    type: array
    items:
      type: array
      items: 
        type: object
        properties: 
          field: 
            type: string
          name:
            type: string
          width:
            type: string
          sortable:
            type: boolean
      
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.