Skip to content

Commit 10ba1a9

Browse files
blakenumbata
authored andcommitted
Add test
1 parent 39c617b commit 10ba1a9

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

spec/openapi_3/boolean_params_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 'Boolean Params' do
6+
def app
7+
Class.new(Grape::API) do
8+
format :json
9+
10+
params do
11+
requires :a_boolean, type: Virtus::Attribute::Boolean
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 boolean types' do
28+
expect(subject).to eq(
29+
'schema' => {
30+
'properties' => {
31+
'a_boolean' => { 'type' => 'boolean' }
32+
},
33+
'required' => ['a_boolean'],
34+
'type' => 'object'
35+
}
36+
)
37+
end
38+
end

0 commit comments

Comments
 (0)