Skip to content

Commit 91e1816

Browse files
committed
Merge pull request #55 from aschuster3/update-swagger-ui
Update Swagger UI assets
2 parents 1c3d71a + 9363e38 commit 91e1816

22 files changed

+787
-139
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Fixed header-based authorization - [@davidbrewer](https://github.com/davidbrewer).
44
* Support Swagger-UI validatorUrl option - [@davidbrewer](https://github.com/davidbrewer).
55
* Support for grape 0.14.x through 0.16.x and grape-swagger 0.11.x through 0.20.x - [@dblock](https://github.com/dblock).
6+
* [#55](https://github.com/ruby-grape/grape-swagger-rails/pull/55): Update Swagger-UI assets and add ability to hide input boxes - [@aschuster93](https://github.com/aschuster93).
67
* Your contribution here.
78

89
### 0.2.0 (February 23, 2016)

README.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ grape | grape-swagger
3131
-------|--------------
3232
0.9.0 | 0.8.0
3333
0.10.0 | 0.9.0
34+
0.16.2 | 0.20.2
3435

3536
## Usage
3637

@@ -45,7 +46,7 @@ Create an initializer (e.g. `./config/initializers/swagger.rb`) and specify the
4546
```ruby
4647
GrapeSwaggerRails.options.url = '/swagger_doc.json'
4748
GrapeSwaggerRails.options.app_url = 'http://swagger.wordnik.com'
48-
``````
49+
```
4950

5051
You can dynamically set `app_url` for each request use a `before_filter_proc`:
5152

@@ -101,6 +102,16 @@ Now you can specify the username and password to your API in the Swagger "API ke
101102
The javascript that loads on the Swagger page automatically encodes the username and password and adds the authorization header to your API request.
102103
See the official Swagger documentation about [Custom Header Parameters](https://github.com/wordnik/swagger-ui#custom-header-parameters---for-basic-auth-etc)
103104

105+
### Pre-fill Authentication
106+
107+
If you will know the Authentication key prior to page load or you wish to set it for debug purposes, you can setup so that the `api_key` field is pre-filled on page load:
108+
109+
```ruby
110+
GrapeSwaggerRails.options.api_key_default_value = 'your_default_value'
111+
```
112+
113+
To set it based on the `current_user` or other request-based parameters, try using it inside of your `before_filter` (See Swagger UI Authorization)
114+
104115
### API Token Authentication
105116

106117
If your application uses token authentication passed as a query param, you can setup Swagger to send the API token along with each request to your API:
@@ -124,6 +135,22 @@ GrapeSwaggerRails.options.before_filter do |request|
124135
end
125136
```
126137

138+
### Hiding the API or Authorization text boxes
139+
140+
If you know in advance that you would like to prevent changing the Swagger API URL, you can hide it using the following:
141+
142+
```ruby
143+
GrapeSwaggerRails.options.hide_url_input = true
144+
```
145+
146+
Similarly, you can hide the Authentication input box by adding this:
147+
148+
```ruby
149+
GrapeSwaggerRails.options.hide_api_key_input = true
150+
```
151+
152+
By default, these options are false.
153+
127154
### Updating Swagger UI from Dist
128155

129156
To update Swagger UI from its [distribution](https://github.com/wordnik/swagger-ui), run `bundle exec rake swagger_ui:dist:update`. Examine the changes carefully.
Loading
73 Bytes
Loading

app/assets/javascripts/grape_swagger_rails/application.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
//= require ./jquery.ba-bbq.min
55
//= require ./handlebars-2.0.0
66
//= require ./marked
7-
//= require ./underscore-min
7+
//= require ./lodash.min
88
//= require ./backbone-min
99
//= require ./swagger-ui.min
10-
//= require ./highlight.7.3.pack
10+
//= require ./highlight.9.1.0.pack
11+
//= require ./js-yaml.min
12+
//= require ./jsoneditor.min
13+
//= require ./object-assign-pollyfill
1114
//= require ./swagger-oauth
1215
//= require ./base64

app/assets/javascripts/grape_swagger_rails/highlight.7.3.pack.js

-1
This file was deleted.

0 commit comments

Comments
 (0)