rspec_api_documentation icon indicating copy to clipboard operation
rspec_api_documentation copied to clipboard

How to handle an array of embedded JSON Objects?

Open jsmestad opened this issue 9 years ago • 3 comments

Given the following example POST payload, how would you configure rspec_api_documentation for the authors key given it is an Array of N-objects?

{
  "book" : {
    "id": "2",
    "name": "Awesome",
    "authors": [
      { "first_name": "Justin", "last_name": "Smestad" }
    ]
  }
}

jsmestad avatar Jan 03 '17 17:01 jsmestad

I'm also trying to figure out how to handle arrays. Did you ever come up with a solution to this?

arronmabrey avatar May 01 '17 13:05 arronmabrey

Nope

jsmestad avatar Jan 24 '18 17:01 jsmestad

something like that:

...
parameter :authors, scope: :book
let(:authors) do
  [{
	first_name: 'Justin', 
	last_name: 'Smestad'
  }]
end

route_description <<-DESC
  authors:
    first_name: :string, :required 
    last_name: :string, :required
DESC

zarapustra avatar Dec 08 '18 02:12 zarapustra