File tree Expand file tree Collapse file tree 5 files changed +39
-1
lines changed
app/views/grape_swagger_rails/application Expand file tree Collapse file tree 5 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 4
4
* Upgraded swagger-ui to v2.1.1 - [ @dblock ] ( https://github.com/dblock ) .
5
5
* Grape-swagger 0.7.2 is no longer supported - [ @dblock ] ( https://github.com/dblock ) .
6
6
* Implemented RuboCop, Ruby-style linter - [ @dblock ] ( https://github.com/dblock ) .
7
+ * [ #31 ] ( https://github.com/ruby-grape/grape-swagger-rails/pull/31 ) : Support Swagger-UI docExpansion option - [ @maruware ] ( https://github.com/maruware ) .
7
8
* Your contribution here.
8
9
9
10
### 0.1.0 (February 5, 2015)
Original file line number Diff line number Diff line change @@ -59,6 +59,13 @@ You can specify additional headers to add to each request:
59
59
GrapeSwaggerRails .options.headers[' Special-Header' ] = ' Some Secret Value'
60
60
```
61
61
62
+ You can set docExpansion with "none" or "list" or "full", default is "none".
63
+ See the official Swagger-UI documentation about [ SwaggerUi Parameters] ( https://github.com/swagger-api/swagger-ui#parameters ) .
64
+
65
+ ``` ruby
66
+ GrapeSwaggerRails .options.doc_expansion = ' list'
67
+ ```
68
+
62
69
Using the ` headers ` option above, you could hard-code Basic Authentication credentials.
63
70
Alternatively, you can configure Basic Authentication through the UI, as described below.
64
71
Original file line number Diff line number Diff line change 28
28
console . log ( data ) ;
29
29
}
30
30
} ,
31
- docExpansion : "none" ,
31
+ docExpansion : options . doc_expansion ,
32
32
apisSorter : "alpha"
33
33
} ) ;
34
34
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ def before_filter(&block)
25
25
api_key_name : 'api_key' , # 'Authorization'
26
26
api_key_type : 'query' , # 'header'
27
27
28
+ doc_expansion : 'none' ,
29
+
28
30
before_filter_proc : nil # Proc used as a controller before filter
29
31
)
30
32
end
Original file line number Diff line number Diff line change 122
122
end
123
123
end
124
124
end
125
+ context '#doc_expansion' do
126
+ context 'set list' do
127
+ before do
128
+ GrapeSwaggerRails . options . doc_expansion = 'list'
129
+ visit '/swagger'
130
+ end
131
+ it 'sets SwaggerUI docExpansion with list' do
132
+ expect ( page . evaluate_script ( 'window.swaggerUi.options.docExpansion == "list"' ) ) . to be true
133
+ end
134
+ end
135
+ context 'set full' do
136
+ before do
137
+ GrapeSwaggerRails . options . doc_expansion = 'full'
138
+ visit '/swagger'
139
+ end
140
+ it 'sets SwaggerUI docExpansion with full' do
141
+ expect ( page . evaluate_script ( 'window.swaggerUi.options.docExpansion == "full"' ) ) . to be true
142
+ end
143
+ end
144
+ context 'not set' do
145
+ before do
146
+ visit '/swagger'
147
+ end
148
+ it 'defaults SwaggerUI docExpansion' do
149
+ expect ( page . evaluate_script ( 'window.swaggerUi.options.docExpansion == "none"' ) ) . to be true
150
+ end
151
+ end
152
+ end
125
153
after do
126
154
GrapeSwaggerRails . options = @options
127
155
end
You can’t perform that action at this time.
0 commit comments