Sha256: 232d7a3d326a4fc514f81a9fa85e4c5457f2f2434477354cd77a4485cf3d81b1
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
require 'spec_helper' describe 'Params Types' do def app Class.new(Grape::API) do format :json desc 'description', nickname: 'desc', params: { input1: { type: Integer, param_type: 'query' } } params do requires :input2, type: String, documentation: { param_type: 'query' } end post :action do end add_swagger_documentation end end subject do get '/swagger_doc/action' expect(last_response.status).to eq 200 body = JSON.parse last_response.body body['apis'].first['operations'].flat_map { |o| o['parameters'] } end it 'reads param type correctly' do expect(subject).to match_array [ { 'paramType' => 'query', 'name' => 'input1', 'description' => '', 'type' => 'integer', 'required' => false, 'allowMultiple' => false, 'format' => 'int32' }, { 'paramType' => 'query', 'name' => 'input2', 'description' => '', 'type' => 'string', 'required' => true, 'allowMultiple' => false } ] end describe 'header params' do def app Class.new(Grape::API) do format :json desc 'Some API', headers: { 'My-Header' => { required: true, description: 'Set this!' } } params do requires :input, type: String end post :action do end add_swagger_documentation end end it 'has consistent types' do types = subject.map { |param| param['type'] } expect(types).to eq(%w(string string)) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grape-swagger-0.11.0 | spec/param_type_spec.rb |
grape-swagger-0.10.5 | spec/param_type_spec.rb |
grape-swagger-0.10.4 | spec/param_type_spec.rb |