Sha256: b6edcea9bb6e4b23da5a8ce9ba65a1c127d4bd27db2033b0c2f22e12013e9b80
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
require 'spec_helper' describe '#539 post params given as array' do let(:app) do Class.new(Grape::API) do namespace :issue_539 do class Element < Grape::Entity expose :id expose :description expose :role end class ArrayOfElements < Grape::Entity expose :elements, documentation: { type: Element, is_array: true, param_type: 'body', required: true } end desc 'create account', params: ArrayOfElements.documentation post do present params end end add_swagger_documentation format: :json end end subject do get '/swagger_doc' JSON.parse(last_response.body) end let(:parameters) { subject['paths']['/issue_539']['post']['parameters'] } let(:definitions) { subject['definitions'] } specify do expect(parameters).to eql( [ { 'in' => 'body', 'name' => 'elements', 'required' => true, 'schema' => { 'type' => 'array', 'items' => { '$ref' => '#/definitions/Element' } } } ] ) end specify do expect(definitions).to eql( 'Element' => { 'type' => 'object', 'properties' => { 'id' => { 'type' => 'string' }, 'description' => { 'type' => 'string' }, 'role' => { 'type' => 'string' } } } ) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grape-swagger-0.26.1 | spec/issues/539_array_post_body_spec.rb |
grape-swagger-0.26.0 | spec/issues/539_array_post_body_spec.rb |
grape-swagger-0.25.3 | spec/issues/539_array_post_body_spec.rb |