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 44* Upgraded swagger-ui to v2.1.1 - [ @dblock ] ( https://github.com/dblock ) .
55* Grape-swagger 0.7.2 is no longer supported - [ @dblock ] ( https://github.com/dblock ) .
66* 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 ) .
78* Your contribution here.
89
910### 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:
5959GrapeSwaggerRails .options.headers[' Special-Header' ] = ' Some Secret Value'
6060```
6161
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+
6269Using the ` headers ` option above, you could hard-code Basic Authentication credentials.
6370Alternatively, you can configure Basic Authentication through the UI, as described below.
6471
Original file line number Diff line number Diff line change 2828 console . log ( data ) ;
2929 }
3030 } ,
31- docExpansion : "none" ,
31+ docExpansion : options . doc_expansion ,
3232 apisSorter : "alpha"
3333 } ) ;
3434
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ def before_filter(&block)
2525 api_key_name : 'api_key' , # 'Authorization'
2626 api_key_type : 'query' , # 'header'
2727
28+ doc_expansion : 'none' ,
29+
2830 before_filter_proc : nil # Proc used as a controller before filter
2931 )
3032end
Original file line number Diff line number Diff line change 122122 end
123123 end
124124 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
125153 after do
126154 GrapeSwaggerRails . options = @options
127155 end
You can’t perform that action at this time.
0 commit comments