Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Swagger UI assets #55

Merged
merged 3 commits into from
May 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Fixed header-based authorization - [@davidbrewer](https://github.com/davidbrewer).
* Support Swagger-UI validatorUrl option - [@davidbrewer](https://github.com/davidbrewer).
* 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).
* [#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).
* Your contribution here.

### 0.2.0 (February 23, 2016)
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ grape | grape-swagger
-------|--------------
0.9.0 | 0.8.0
0.10.0 | 0.9.0
0.16.2 | 0.20.2

## Usage

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

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

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

### Pre-fill Authentication

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:

```ruby
GrapeSwaggerRails.options.api_key_default_value = 'your_default_value'
```

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)

### API Token Authentication

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:
Expand All @@ -124,6 +135,22 @@ GrapeSwaggerRails.options.before_filter do |request|
end
```

### Hiding the API or Authorization text boxes

If you know in advance that you would like to prevent changing the Swagger API URL, you can hide it using the following:

```ruby
GrapeSwaggerRails.options.hide_url_input = true
```

Similarly, you can hide the Authentication input box by adding this:

```ruby
GrapeSwaggerRails.options.hide_api_key_input = true
```

By default, these options are false.

### Updating Swagger UI from Dist

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.
Expand Down
Binary file added app/assets/images/grape_swagger_rails/collapse.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/grape_swagger_rails/expand.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions app/assets/javascripts/grape_swagger_rails/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
//= require ./jquery.ba-bbq.min
//= require ./handlebars-2.0.0
//= require ./marked
//= require ./underscore-min
//= require ./lodash.min
//= require ./backbone-min
//= require ./swagger-ui.min
//= require ./highlight.7.3.pack
//= require ./highlight.9.1.0.pack
//= require ./js-yaml.min
//= require ./jsoneditor.min
//= require ./object-assign-pollyfill
//= require ./swagger-oauth
//= require ./base64

This file was deleted.

Loading