rspec_api_documentation icon indicating copy to clipboard operation
rspec_api_documentation copied to clipboard

Parameters for nested array

Open gregdymek opened this issue 5 years ago • 3 comments

let's say I have a structure like:

{
  data: [
    {
      id: 5,
      name: 'test'
    },
    {
      id: 6,
      name: 'test2'
    }
  ]
}

is there a way I can document the nested fields so as a result I will get openapi generated correctly (so in swagger I can add these items from the UI) ?

gregdymek avatar Jan 03 '20 18:01 gregdymek

I was trying with something like this:

parameter :data, type: :array
parameter :id, type: :string, scope: :data
parameter :name, type: :string, scope: :data

but it didn't work

gregdymek avatar Jan 03 '20 18:01 gregdymek

I'm facing the same issue

daniel-illi avatar Oct 20 '20 09:10 daniel-illi

I guess one can use

parameter :data, type: array
parameter :id, type: integer, scope: 'data[]'

I also want a conversation about this part in #413, cause I'm facing the same issue and want to fix it in the way most users will be happy

ngoral avatar Feb 17 '22 08:02 ngoral