File tree 1 file changed +45
-0
lines changed
1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'desc is_array option' do
6
+ let ( :app ) do
7
+ class User < Grape ::Entity
8
+ expose :name
9
+ end
10
+ Class . new ( Grape ::API ) do
11
+ namespace :hash do
12
+ desc 'Get users' ,
13
+ success : User ,
14
+ is_array : true
15
+ get { }
16
+ end
17
+ namespace :block do
18
+ desc 'Get users' do
19
+ success User
20
+ is_array true
21
+ end
22
+ get { }
23
+ end
24
+
25
+ add_swagger_documentation format : :json
26
+ end
27
+ end
28
+
29
+ subject do
30
+ get '/swagger_doc'
31
+ JSON . parse ( last_response . body )
32
+ end
33
+
34
+ def type_in_success_response_schema ( style )
35
+ subject [ 'paths' ] [ "/#{ style } " ] [ 'get' ] [ 'responses' ] [ '200' ] [ 'schema' ] [ 'type' ]
36
+ end
37
+
38
+ context 'in hash style' do
39
+ it { expect ( type_in_success_response_schema ( 'hash' ) ) . to eq 'array' }
40
+ end
41
+
42
+ context 'in block style' do
43
+ it { expect ( type_in_success_response_schema ( 'block' ) ) . to eq 'array' }
44
+ end
45
+ end
You can’t perform that action at this time.
0 commit comments