Skip to content

Commit 95330c8

Browse files
blakenumbata
authored andcommitted
Add test
1 parent 2d5f364 commit 95330c8

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

spec/openapi_3/float_api_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frozen_string_literal: true
2+
3+
require 'spec_helper'
4+
5+
describe 'Float Params' do
6+
def app
7+
Class.new(Grape::API) do
8+
format :json
9+
10+
params do
11+
requires :a_float, type: Float
12+
end
13+
post :splines do
14+
end
15+
16+
add_swagger_documentation openapi_version: '3.0'
17+
end
18+
end
19+
20+
subject do
21+
get '/swagger_doc/splines'
22+
expect(last_response.status).to eq 200
23+
body = JSON.parse last_response.body
24+
body['paths']['/splines']['post']['requestBody']['content']['application/x-www-form-urlencoded']
25+
end
26+
27+
it 'converts float types' do
28+
expect(subject).to eq(
29+
'schema' => {
30+
'properties' => {
31+
'a_float' => { 'format' => 'float', 'type' => 'number' }
32+
},
33+
'required' => ['a_float'],
34+
'type' => 'object'
35+
}
36+
)
37+
end
38+
end

0 commit comments

Comments
 (0)