2015-02-01 11:53:18 +08:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'Float Params' do
|
|
|
|
def app
|
|
|
|
Class.new(Grape::API) do
|
|
|
|
format :json
|
|
|
|
|
|
|
|
params do
|
2015-03-03 19:52:26 +08:00
|
|
|
requires :a_float, type: Float
|
2015-02-01 11:53:18 +08:00
|
|
|
end
|
|
|
|
post :splines do
|
|
|
|
end
|
|
|
|
|
|
|
|
add_swagger_documentation
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
subject do
|
|
|
|
get '/swagger_doc/splines'
|
|
|
|
expect(last_response.status).to eq 200
|
|
|
|
body = JSON.parse last_response.body
|
2015-10-05 02:05:22 +08:00
|
|
|
body['paths']['/splines']['post']['parameters']
|
2015-02-01 11:53:18 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'converts float types' do
|
|
|
|
expect(subject).to eq [
|
2016-05-07 03:00:36 +08:00
|
|
|
{ 'in' => 'formData', 'name' => 'a_float', 'type' => 'number', 'required' => true, 'format' => 'float' }
|
2015-02-01 11:53:18 +08:00
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|