grape-swagger-rails 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop_todo.yml +1 -1
- data/.travis.yml +13 -2
- data/CHANGELOG.md +9 -1
- data/README.md +16 -3
- data/RELEASING.md +1 -1
- data/app/views/grape_swagger_rails/application/index.html.erb +19 -5
- data/grape-swagger-rails.gemspec +3 -2
- data/lib/grape-swagger-rails/version.rb +1 -1
- data/lib/tasks/swagger_ui.rake +2 -2
- data/spec/features/swagger_spec.rb +34 -2
- metadata +21 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2fbbe31ef3358e338372a0e2ad589acff22eec986accfaf7169a5af2357701d6
|
4
|
+
data.tar.gz: 6b9672241d274f8b350836b3877d0bd79579d6b499ecf963f66b3aeae4c8303c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e9d7ae03cf73df5422183cc1485fb6cc915900fc5cfeaafab6b494491238199ae99094feecf4be65c9a794b93cad21cc7cb6e01c09bc6ae55fc66368ce1f116
|
7
|
+
data.tar.gz: 4e5b3c98c11a2316fd2712ee612cabd009ea3baf0e9bdaeacca8a0d497aee8879e27afbd3dc1b102ea83eb0abae7e5d8ecb04b89bb5750b7dcdf591cf2fc1071
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2015-08-19 12:23:54 -0400 using RuboCop version 0.
|
3
|
+
# on 2015-08-19 12:23:54 -0400 using RuboCop version 0.38.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
data/.travis.yml
CHANGED
@@ -1,8 +1,20 @@
|
|
1
|
-
|
1
|
+
addons:
|
2
|
+
firefox: 54.0
|
3
|
+
|
4
|
+
services:
|
5
|
+
- xvfb
|
2
6
|
|
3
7
|
before_install:
|
8
|
+
- wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
|
9
|
+
- mkdir geckodriver
|
10
|
+
- tar -xzf geckodriver-v0.18.0-linux64.tar.gz -C geckodriver
|
11
|
+
- export PATH=$PATH:$PWD/geckodriver
|
12
|
+
- gem install bundler -v'< 2'
|
13
|
+
|
14
|
+
before_script:
|
4
15
|
- "export DISPLAY=:99.0"
|
5
16
|
- "sh -e /etc/init.d/xvfb start"
|
17
|
+
- sleep 3 # give xvfb some time to start
|
6
18
|
|
7
19
|
language: ruby
|
8
20
|
|
@@ -39,4 +51,3 @@ matrix:
|
|
39
51
|
- rvm: ruby-head
|
40
52
|
- rvm: jruby-head
|
41
53
|
- rvm: rbx-2
|
42
|
-
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
+
### Next Release
|
2
|
+
|
3
|
+
* Your contribution here.
|
4
|
+
|
5
|
+
### 0.3.1 (February 16, 2019)
|
6
|
+
|
7
|
+
* [#82](https://github.com/ruby-grape/grape-swagger-rails/pull/82): Fixed api_key_default_value - [@konto-andrzeja](https://github.com/konto-andrzeja).
|
8
|
+
* [#84](https://github.com/ruby-grape/grape-swagger-rails/pull/84): Added the token api_auth type - [@Jack12816](https://github.com/Jack12816).
|
9
|
+
|
1
10
|
### 0.3.0 (September 22, 2016)
|
2
11
|
|
3
12
|
* [#70](https://github.com/ruby-grape/grape-swagger-rails/pull/70): Rails 5 support - [@serggl](https://github.com/serggl).
|
4
13
|
* [#68](https://github.com/ruby-grape/grape-swagger-rails/pull/68): Added danger, PR linter - [@dblock](https://github.com/dblock).
|
5
|
-
* Your contribution here.
|
6
14
|
|
7
15
|
### 0.2.2 (July 13, 2016)
|
8
16
|
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/grape-swagger-rails.svg)](http://badge.fury.io/rb/grape-swagger-rails)
|
4
4
|
[![Build Status](https://travis-ci.org/ruby-grape/grape-swagger-rails.svg)](https://travis-ci.org/ruby-grape/grape-swagger-rails)
|
5
|
-
[![Dependency Status](https://gemnasium.com/ruby-grape/grape-swagger-rails.svg)](https://gemnasium.com/ruby-grape/grape-swagger-rails)
|
6
5
|
[![Code Climate](https://codeclimate.com/github/ruby-grape/grape-swagger-rails/badges/gpa.svg)](https://codeclimate.com/github/ruby-grape/grape-swagger-rails)
|
7
6
|
|
8
7
|
Swagger UI as Rails Engine for grape-swagger gem.
|
@@ -69,7 +68,7 @@ GrapeSwaggerRails.options.headers['Special-Header'] = 'Some Secret Value'
|
|
69
68
|
```
|
70
69
|
|
71
70
|
You can set docExpansion with "none" or "list" or "full", default is "none".
|
72
|
-
See the official Swagger-UI documentation about [SwaggerUi Parameters](https://github.com/swagger-api/swagger-ui#parameters).
|
71
|
+
See the official Swagger-UI documentation about [SwaggerUi Parameters](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#parameters).
|
73
72
|
|
74
73
|
```ruby
|
75
74
|
GrapeSwaggerRails.options.doc_expansion = 'list'
|
@@ -77,7 +76,7 @@ GrapeSwaggerRails.options.doc_expansion = 'list'
|
|
77
76
|
|
78
77
|
You can set supportedSubmitMethods with an array of the supported HTTP methods, default is `%w{ get post put delete patch }`.
|
79
78
|
|
80
|
-
See the official Swagger-UI documentation about [SwaggerUi Parameters](https://github.com/swagger-api/swagger-ui#parameters).
|
79
|
+
See the official Swagger-UI documentation about [SwaggerUi Parameters](https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#parameters).
|
81
80
|
|
82
81
|
```ruby
|
83
82
|
GrapeSwaggerRails.options.supported_submit_methods = ["get"]
|
@@ -129,6 +128,20 @@ GrapeSwaggerRails.options.api_key_name = 'api_token'
|
|
129
128
|
GrapeSwaggerRails.options.api_key_type = 'query'
|
130
129
|
```
|
131
130
|
|
131
|
+
If your application used token authentication passed as a header, like Rails does (`authenticate_or_request_with_http_token`), you can configure Swagger to send the token in this form:
|
132
|
+
|
133
|
+
```
|
134
|
+
Authorization: Token token="WCZZYjnOQFUYfJIN2ShH1iD24UHo58A6TI"
|
135
|
+
```
|
136
|
+
|
137
|
+
by specify:
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
GrapeSwaggerRails.options.api_auth = 'token'
|
141
|
+
GrapeSwaggerRails.options.api_key_name = 'Authorization'
|
142
|
+
GrapeSwaggerRails.options.api_key_type = 'header'
|
143
|
+
```
|
144
|
+
|
132
145
|
You can use the ```api_key``` input box to fill in your API token.
|
133
146
|
### Swagger UI Authorization
|
134
147
|
|
data/RELEASING.md
CHANGED
@@ -15,6 +15,12 @@
|
|
15
15
|
<%=raw "headers.header_#{index} = new SwaggerClient.ApiKeyAuthorization('#{CGI.escapeHTML(key)}', '#{CGI.escapeHTML(value)}', 'header');" %>
|
16
16
|
<% end %>
|
17
17
|
|
18
|
+
<% if GrapeSwaggerRails.options.api_key_default_value.try(:strip).present? &&
|
19
|
+
GrapeSwaggerRails.options.headers['Authorization'].blank? %>
|
20
|
+
<% headers_count = GrapeSwaggerRails.options.headers.count %>
|
21
|
+
<%= raw "headers.header_#{headers_count} = getApiKeyAuthorization();" %>
|
22
|
+
<% end %>
|
23
|
+
|
18
24
|
window.swaggerUi = new SwaggerUi({
|
19
25
|
url: options.app_url + options.url,
|
20
26
|
dom_id: "swagger-ui-container",
|
@@ -28,7 +34,6 @@
|
|
28
34
|
console.log(swaggerUi);
|
29
35
|
}
|
30
36
|
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
31
|
-
addApiKeyAuthorization();
|
32
37
|
},
|
33
38
|
onFailure: function(data) {
|
34
39
|
if('console' in window) {
|
@@ -41,18 +46,27 @@
|
|
41
46
|
apisSorter: "alpha"
|
42
47
|
});
|
43
48
|
|
44
|
-
function
|
49
|
+
function getApiKeyAuthorization() {
|
45
50
|
var key = $('#input_apiKey')[0].value;
|
46
51
|
|
47
52
|
if (key && key.trim() != "") {
|
48
53
|
if (options.api_auth == 'basic') {
|
49
54
|
key = "Basic " + Base64.encode(key);
|
50
55
|
} else if (options.api_auth == 'bearer') {
|
51
|
-
key = "Bearer " + key
|
56
|
+
key = "Bearer " + key;
|
57
|
+
} else if (options.api_auth == 'token') {
|
58
|
+
key = 'Token token="' + key + '"';
|
52
59
|
}
|
53
|
-
|
60
|
+
return new SwaggerClient.ApiKeyAuthorization(options.api_key_name, key, options.api_key_type);
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
function addApiKeyAuthorization() {
|
65
|
+
var apiKeyAuthorization = getApiKeyAuthorization();
|
66
|
+
if (apiKeyAuthorization) {
|
67
|
+
window.swaggerUi.api.clientAuthorizations.add("key", apiKeyAuthorization);
|
54
68
|
}
|
55
|
-
|
69
|
+
}
|
56
70
|
|
57
71
|
$('#input_apiKey').change(addApiKeyAuthorization);
|
58
72
|
|
data/grape-swagger-rails.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
|
19
19
|
spec.add_dependency 'railties', '>= 3.2.12'
|
20
20
|
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.15'
|
22
22
|
spec.add_development_dependency 'rake'
|
23
23
|
spec.add_development_dependency 'git'
|
24
24
|
spec.add_development_dependency 'rspec-rails'
|
@@ -34,7 +34,8 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_development_dependency 'sprockets'
|
35
35
|
spec.add_development_dependency 'rack', '~> 1.6'
|
36
36
|
spec.add_development_dependency 'rack-cors'
|
37
|
-
spec.add_development_dependency 'rubocop', '0.
|
37
|
+
spec.add_development_dependency 'rubocop', '0.38.0'
|
38
38
|
spec.add_development_dependency 'mime-types', '< 3.0'
|
39
39
|
spec.add_development_dependency 'rack-no_animations'
|
40
|
+
spec.add_development_dependency 'nokogiri', '< 1.7.0'
|
40
41
|
end
|
data/lib/tasks/swagger_ui.rake
CHANGED
@@ -36,7 +36,7 @@ namespace :swagger_ui do
|
|
36
36
|
'object-assign-pollyfill.js',
|
37
37
|
'swagger-oauth.js',
|
38
38
|
'base64.js'
|
39
|
-
]
|
39
|
+
].freeze
|
40
40
|
javascript_files = Dir["#{root}/app/assets/javascripts/grape_swagger_rails/*.js"].map { |f|
|
41
41
|
f.split('/').last
|
42
42
|
} - ['application.js']
|
@@ -61,7 +61,7 @@ namespace :swagger_ui do
|
|
61
61
|
CSS_FILES = [
|
62
62
|
'reset.css',
|
63
63
|
'screen.css'
|
64
|
-
]
|
64
|
+
].freeze
|
65
65
|
css_files = Dir["#{root}/app/assets/stylesheets/grape_swagger_rails/*.css"].map { |f|
|
66
66
|
f.split('/').last
|
67
67
|
} - ['application.css']
|
@@ -19,8 +19,8 @@ describe 'Swagger' do
|
|
19
19
|
|
20
20
|
it 'evaluates config options correctly' do
|
21
21
|
visit '/swagger'
|
22
|
-
|
23
|
-
expect(
|
22
|
+
page_options = page.evaluate_script("$('html').data('swagger-options')").symbolize_keys
|
23
|
+
expect(page_options).to eq(@options.marshal_dump)
|
24
24
|
end
|
25
25
|
|
26
26
|
context '#headers' do
|
@@ -49,6 +49,21 @@ describe 'Swagger' do
|
|
49
49
|
expect(page).to have_css 'span.hljs-string', text: 'Another Value'
|
50
50
|
end
|
51
51
|
end
|
52
|
+
context '#api_key_default_value' do
|
53
|
+
before do
|
54
|
+
GrapeSwaggerRails.options.api_auth = 'bearer'
|
55
|
+
GrapeSwaggerRails.options.api_key_name = 'Authorization'
|
56
|
+
GrapeSwaggerRails.options.api_key_type = 'header'
|
57
|
+
GrapeSwaggerRails.options.api_key_default_value = 'token'
|
58
|
+
visit '/swagger'
|
59
|
+
end
|
60
|
+
it 'adds an Authorization header' do
|
61
|
+
headers = page.evaluate_script('swaggerUi.api.clientAuthorizations')['authz']
|
62
|
+
last_header = headers.fetch("header_#{headers.length - 1}", {})
|
63
|
+
expect(last_header.slice('name', 'value'))
|
64
|
+
.to eq('name' => 'Authorization', 'value' => 'Bearer token')
|
65
|
+
end
|
66
|
+
end
|
52
67
|
context '#api_auth:basic' do
|
53
68
|
before do
|
54
69
|
GrapeSwaggerRails.options.api_auth = 'basic'
|
@@ -83,6 +98,23 @@ describe 'Swagger' do
|
|
83
98
|
expect(page).to have_css 'span.hljs-string', text: 'Bearer token'
|
84
99
|
end
|
85
100
|
end
|
101
|
+
context '#api_auth:token and #api_key_type:header' do
|
102
|
+
before do
|
103
|
+
GrapeSwaggerRails.options.api_auth = 'token'
|
104
|
+
GrapeSwaggerRails.options.api_key_name = 'Authorization'
|
105
|
+
GrapeSwaggerRails.options.api_key_type = 'header'
|
106
|
+
visit '/swagger'
|
107
|
+
end
|
108
|
+
it 'adds an Authorization header' do
|
109
|
+
page.execute_script("$('#input_apiKey').val('token')")
|
110
|
+
page.execute_script("$('#input_apiKey').trigger('change')")
|
111
|
+
find('#endpointListTogger_headers', visible: true).click
|
112
|
+
first('span[class="http_method"] a', visible: true).click
|
113
|
+
click_button 'Try it out!'
|
114
|
+
expect(page).to have_css 'span.hljs-attr', text: 'Authorization'
|
115
|
+
expect(page).to have_css 'span.hljs-string', text: 'Token token'
|
116
|
+
end
|
117
|
+
end
|
86
118
|
context '#api_auth:token' do
|
87
119
|
before do
|
88
120
|
GrapeSwaggerRails.options.api_key_name = 'api_token'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-swagger-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Logunov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.15'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.15'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -254,14 +254,14 @@ dependencies:
|
|
254
254
|
requirements:
|
255
255
|
- - '='
|
256
256
|
- !ruby/object:Gem::Version
|
257
|
-
version: 0.
|
257
|
+
version: 0.38.0
|
258
258
|
type: :development
|
259
259
|
prerelease: false
|
260
260
|
version_requirements: !ruby/object:Gem::Requirement
|
261
261
|
requirements:
|
262
262
|
- - '='
|
263
263
|
- !ruby/object:Gem::Version
|
264
|
-
version: 0.
|
264
|
+
version: 0.38.0
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
266
|
name: mime-types
|
267
267
|
requirement: !ruby/object:Gem::Requirement
|
@@ -290,6 +290,20 @@ dependencies:
|
|
290
290
|
- - ">="
|
291
291
|
- !ruby/object:Gem::Version
|
292
292
|
version: '0'
|
293
|
+
- !ruby/object:Gem::Dependency
|
294
|
+
name: nokogiri
|
295
|
+
requirement: !ruby/object:Gem::Requirement
|
296
|
+
requirements:
|
297
|
+
- - "<"
|
298
|
+
- !ruby/object:Gem::Version
|
299
|
+
version: 1.7.0
|
300
|
+
type: :development
|
301
|
+
prerelease: false
|
302
|
+
version_requirements: !ruby/object:Gem::Requirement
|
303
|
+
requirements:
|
304
|
+
- - "<"
|
305
|
+
- !ruby/object:Gem::Version
|
306
|
+
version: 1.7.0
|
293
307
|
description: Swagger UI as Rails Engine for grape-swagger gem
|
294
308
|
email:
|
295
309
|
- unlovedru@gmail.com
|
@@ -416,8 +430,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
416
430
|
- !ruby/object:Gem::Version
|
417
431
|
version: '0'
|
418
432
|
requirements: []
|
419
|
-
|
420
|
-
rubygems_version: 2.6.6
|
433
|
+
rubygems_version: 3.0.2
|
421
434
|
signing_key:
|
422
435
|
specification_version: 4
|
423
436
|
summary: Swagger UI as Rails Engine for grape-swagger gem
|