Sha256: 6590b4126d11a2092597b82f51382ae4b6889703e80380c1387e0207d80b9726
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
require 'spec_helper' describe 'Range Params' do def app Class.new(Grape::API) do format :json params do requires :letter, type: String, values: 'a'..'z' end post :letter do end params do requires :number, type: Integer, values: -5..5 end post :integer do end add_swagger_documentation end end subject(:letter) do get '/swagger_doc/letter' expect(last_response.status).to eq 200 body = JSON.parse last_response.body body['apis'].first['operations'].first['parameters'] end it 'has letter range values' do expect(letter).to eq [ { 'paramType' => 'form', 'name' => 'letter', 'description' => nil, 'type' => 'string', 'required' => true, 'allowMultiple' => false, 'enum' => ('a'..'z').to_a } ] end subject(:number) do get '/swagger_doc/integer' expect(last_response.status).to eq 200 body = JSON.parse last_response.body body['apis'].first['operations'].first['parameters'] end it 'has number range values' do expect(number).to eq [ { 'paramType' => 'form', 'name' => 'number', 'description' => nil, 'type' => 'integer', 'required' => true, 'allowMultiple' => false, 'format' => 'int32', 'enum' => (-5..5).to_a } ] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
grape-swagger-0.10.1 | spec/range_values_spec.rb |
grape-swagger-0.10.0 | spec/range_values_spec.rb |