Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rswag nested objects, rswag syntax

I have a project where I have nested objects. I have tried to figure out the correct syntax for nested array. This is something that I have tired (among of the many other things):

parameter name: :measurement, in: :body, schema: {
  type: :object,
  properties: {
    measurement_code: { type: :string },
  },
  type: :array_of_objects,
  measure: { type: :array },
  items: {
    value: { type: :integer }
    name: { type: :string }
    id: { type: :integer }
  },
  required: []
}

The example data that I am sending:

{"measurement_code"=>"918031199-7",
 :measure=>
  [
    {
    "id": 1,
    "value": 8049,
    "name": "Temporibus quam et ipsum blanditiis hic."
    },
    {
    "id": 2,
    "value": 76060,
    "name": "Sint omnis."
    }]
  }
}
like image 709
AnttiKiiveri Avatar asked Jun 15 '18 07:06

AnttiKiiveri


1 Answers

This works as the rswag syntax for array of objects:

  properties: {
    measurement_code: { type: :string },
    measure: {
      type: :array,
      items: {
        properties: {
          value: { type: :integer },
          name: { type: :string },
          id: { type: :integer }
        }
      },
    },
  }
like image 97
AnttiKiiveri Avatar answered Nov 13 '22 12:11

AnttiKiiveri