grape-swagger-rails 0.0.8 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +3 -0
- data/.travis.yml +10 -0
- data/Gemfile +1 -2
- data/README.md +35 -21
- data/Rakefile +25 -0
- data/app/assets/images/grape_swagger_rails/explorer_icons.png +0 -0
- data/app/assets/javascripts/grape_swagger_rails/application.js +2 -13
- data/app/assets/javascripts/grape_swagger_rails/swagger-oauth.js +211 -0
- data/app/assets/javascripts/grape_swagger_rails/swagger-ui.min.js +1 -1
- data/app/assets/javascripts/grape_swagger_rails/swagger.js +1521 -1398
- data/app/assets/stylesheets/grape_swagger_rails/application.css +4 -13
- data/app/assets/stylesheets/grape_swagger_rails/reset.css +125 -0
- data/app/assets/stylesheets/grape_swagger_rails/screen.css.erb +545 -391
- data/app/controllers/grape_swagger_rails/application_controller.rb +3 -3
- data/app/views/grape_swagger_rails/application/index.html.erb +13 -7
- data/grape-swagger-rails.gemspec +21 -8
- data/lib/grape-swagger-rails.rb +16 -13
- data/lib/grape-swagger-rails/engine.rb +1 -0
- data/lib/grape-swagger-rails/version.rb +1 -1
- data/lib/javascripts/base64.js +134 -0
- data/lib/tasks/swagger_ui.rake +98 -0
- data/spec/dummy/.gitignore +16 -0
- data/spec/dummy/Rakefile +5 -0
- data/spec/dummy/app/api/api.rb +31 -0
- data/spec/dummy/app/assets/javascripts/application.js +3 -0
- data/spec/dummy/app/assets/stylesheets/application.css +4 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/welcome_controller.rb +4 -0
- data/spec/dummy/app/views/layouts/_messages.html.erb +5 -0
- data/spec/dummy/app/views/layouts/application.html.erb +16 -0
- data/spec/dummy/app/views/welcome/index.html.erb +3 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +8 -0
- data/spec/dummy/bin/rake +8 -0
- data/spec/dummy/bin/spring +18 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/environment.rb +3 -0
- data/spec/dummy/config/environments/development.rb +34 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +1 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +1 -0
- data/spec/dummy/config/initializers/session_store.rb +1 -0
- data/spec/dummy/config/initializers/swagger.rb +3 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/config/secrets.yml +8 -0
- data/spec/dummy/public/.gitignore +2 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +5 -0
- data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
- data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
- data/spec/features/grape-swagger-rails_spec.rb +15 -0
- data/spec/features/swagger_spec.rb +116 -0
- data/spec/features/welcome_spec.rb +10 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/capybara.rb +5 -0
- data/spec/support/rails.rb +1 -0
- metadata +283 -31
- data/app/assets/javascripts/grape_swagger_rails/swagger-ui.js.erb +0 -2129
- data/app/assets/stylesheets/grape_swagger_rails/highlight.default.css +0 -135
@@ -1,11 +1,11 @@
|
|
1
1
|
module GrapeSwaggerRails
|
2
2
|
class ApplicationController < ActionController::Base
|
3
3
|
before_filter do
|
4
|
-
if GrapeSwaggerRails.options.
|
5
|
-
instance_exec(request, &GrapeSwaggerRails.options.
|
4
|
+
if GrapeSwaggerRails.options.before_filter
|
5
|
+
instance_exec(request, &GrapeSwaggerRails.options.before_filter)
|
6
6
|
end
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def index
|
10
10
|
end
|
11
11
|
end
|
@@ -1,19 +1,18 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
|
-
<html data-swagger-options="<%= GrapeSwaggerRails.options.to_json %>">
|
2
|
+
<html data-swagger-options="<%= GrapeSwaggerRails.options.to_h.to_json %>">
|
3
3
|
<head>
|
4
|
-
<title
|
4
|
+
<title><%= GrapeSwaggerRails.options.app_name || 'Swagger UI' %></title>
|
5
5
|
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
6
6
|
<%= stylesheet_link_tag 'grape_swagger_rails/application.css' %>
|
7
7
|
<%= javascript_include_tag 'grape_swagger_rails/application.js' %>
|
8
8
|
<script type="text/javascript">
|
9
9
|
$(function () {
|
10
10
|
var options = $("html").data('swagger-options');
|
11
|
-
|
11
|
+
|
12
12
|
window.swaggerUi = new SwaggerUi({
|
13
|
-
url: options.url,
|
13
|
+
url: options.app_url + options.url,
|
14
14
|
dom_id:"swagger-ui-container",
|
15
15
|
supportHeaderParams: true,
|
16
|
-
headers: options.headers,
|
17
16
|
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
18
17
|
onComplete: function(swaggerApi, swaggerUi){
|
19
18
|
if('console' in window) {
|
@@ -34,22 +33,29 @@
|
|
34
33
|
|
35
34
|
$('#input_apiKey').change(function() {
|
36
35
|
var key = $('#input_apiKey')[0].value;
|
37
|
-
|
36
|
+
|
38
37
|
if(key && key.trim() != "") {
|
39
38
|
if (options.api_auth == 'basic') {
|
40
39
|
key = "Basic " + Base64.encode(key);
|
40
|
+
} else if (options.api_auth == 'bearer') {
|
41
|
+
key = "Bearer " + key
|
41
42
|
}
|
42
43
|
window.authorizations.add("key", new ApiKeyAuthorization(options.api_key_name, key, options.api_key_type));
|
43
44
|
} else {
|
44
45
|
window.authorizations.add("key", null);
|
45
46
|
}
|
46
47
|
})
|
48
|
+
|
49
|
+
<% GrapeSwaggerRails.options.headers.each_pair do |key, value| %>
|
50
|
+
<%=raw "window.authorizations.add('key', new ApiKeyAuthorization('#{CGI.escapeHTML(key)}', '#{CGI.escapeHTML(value)}', 'header'));" %>
|
51
|
+
<% end %>
|
52
|
+
|
47
53
|
window.swaggerUi.load();
|
48
54
|
});
|
49
55
|
</script>
|
50
56
|
</head>
|
51
57
|
|
52
|
-
<body>
|
58
|
+
<body class="swagger-section">
|
53
59
|
<div id='header'>
|
54
60
|
<div class="swagger-ui-wrap">
|
55
61
|
<a id="logo" href="<%= GrapeSwaggerRails.options.app_url %>"><%= GrapeSwaggerRails.options.app_name %></a>
|
data/grape-swagger-rails.gemspec
CHANGED
@@ -6,18 +6,31 @@ require 'grape-swagger-rails/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'grape-swagger-rails'
|
8
8
|
spec.version = GrapeSwaggerRails::VERSION
|
9
|
-
spec.authors = ['
|
10
|
-
spec.email = ['
|
11
|
-
spec.description =
|
12
|
-
spec.summary =
|
13
|
-
spec.homepage = ''
|
9
|
+
spec.authors = ['Alexander Logunov']
|
10
|
+
spec.email = ['unlovedru@gmail.com']
|
11
|
+
spec.description = 'Swagger UI as Rails Engine for grape-swagger gem'
|
12
|
+
spec.summary = 'Swagger UI as Rails Engine for grape-swagger gem'
|
13
|
+
spec.homepage = 'https://github.com/BrandyMint/grape-swagger-rails'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.test_files = `git ls-files spec`.split($/)
|
16
17
|
spec.require_paths = %w(lib)
|
17
18
|
|
18
|
-
spec.add_development_dependency 'bundler', '~> 1.3'
|
19
|
-
spec.add_development_dependency 'rake'
|
20
19
|
spec.add_dependency 'railties', '>= 3.2.12'
|
21
|
-
#spec.add_dependency 'rubyzip', '~> 0.9.9'
|
22
20
|
spec.add_dependency 'grape-swagger', '~> 0.7.2'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'git'
|
25
|
+
spec.add_development_dependency 'rspec-rails'
|
26
|
+
spec.add_development_dependency 'capybara'
|
27
|
+
spec.add_development_dependency 'grape'
|
28
|
+
spec.add_development_dependency 'selenium-webdriver'
|
29
|
+
spec.add_development_dependency 'sass-rails'
|
30
|
+
spec.add_development_dependency 'uglifier'
|
31
|
+
spec.add_development_dependency 'coffee-rails'
|
32
|
+
spec.add_development_dependency 'jquery-rails'
|
33
|
+
spec.add_development_dependency 'grape-swagger-ui'
|
34
|
+
spec.add_development_dependency 'sprockets'
|
35
|
+
spec.add_development_dependency 'rack-cors'
|
23
36
|
end
|
data/lib/grape-swagger-rails.rb
CHANGED
@@ -1,28 +1,31 @@
|
|
1
1
|
require "grape-swagger-rails/engine"
|
2
2
|
|
3
3
|
module GrapeSwaggerRails
|
4
|
-
class Options <
|
5
|
-
def
|
6
|
-
|
4
|
+
class Options < OpenStruct
|
5
|
+
def before_filter(&block)
|
6
|
+
if block_given?
|
7
|
+
self.before_filter_proc = block
|
8
|
+
else
|
9
|
+
self.before_filter_proc
|
10
|
+
end
|
7
11
|
end
|
8
12
|
end
|
9
|
-
|
13
|
+
|
10
14
|
mattr_accessor :options
|
11
|
-
|
15
|
+
|
12
16
|
self.options = Options.new(
|
13
|
-
|
17
|
+
|
14
18
|
url: '/swagger_doc.json',
|
15
19
|
app_name: 'Swagger',
|
16
20
|
app_url: 'http://swagger.wordnik.com',
|
17
|
-
|
21
|
+
|
18
22
|
headers: {},
|
19
|
-
|
20
|
-
api_auth: '', # 'basic'
|
23
|
+
|
24
|
+
api_auth: '', # 'basic' or 'bearer'
|
21
25
|
api_key_name: 'api_key', # 'Authorization'
|
22
26
|
api_key_type: 'query', # 'header'
|
23
|
-
|
24
|
-
|
27
|
+
|
28
|
+
before_filter_proc: nil # Proc used as a controller before filter
|
25
29
|
)
|
26
|
-
|
27
|
-
end
|
28
30
|
|
31
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Base64 encode / decode
|
4
|
+
* http://www.webtoolkit.info/
|
5
|
+
*
|
6
|
+
**/
|
7
|
+
var Base64 = {
|
8
|
+
|
9
|
+
// private property
|
10
|
+
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
|
11
|
+
|
12
|
+
// public method for encoding
|
13
|
+
encode : function(input) {
|
14
|
+
var output = "";
|
15
|
+
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
16
|
+
var i = 0;
|
17
|
+
|
18
|
+
input = Base64._utf8_encode(input);
|
19
|
+
|
20
|
+
while (i < input.length) {
|
21
|
+
|
22
|
+
chr1 = input.charCodeAt(i++);
|
23
|
+
chr2 = input.charCodeAt(i++);
|
24
|
+
chr3 = input.charCodeAt(i++);
|
25
|
+
|
26
|
+
enc1 = chr1 >> 2;
|
27
|
+
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
28
|
+
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
29
|
+
enc4 = chr3 & 63;
|
30
|
+
|
31
|
+
if (isNaN(chr2)) {
|
32
|
+
enc3 = enc4 = 64;
|
33
|
+
} else if (isNaN(chr3)) {
|
34
|
+
enc4 = 64;
|
35
|
+
}
|
36
|
+
|
37
|
+
output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) + this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
|
38
|
+
|
39
|
+
}
|
40
|
+
|
41
|
+
return output;
|
42
|
+
},
|
43
|
+
|
44
|
+
// public method for decoding
|
45
|
+
decode : function(input) {
|
46
|
+
var output = "";
|
47
|
+
var chr1, chr2, chr3;
|
48
|
+
var enc1, enc2, enc3, enc4;
|
49
|
+
var i = 0;
|
50
|
+
|
51
|
+
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
52
|
+
|
53
|
+
while (i < input.length) {
|
54
|
+
|
55
|
+
enc1 = this._keyStr.indexOf(input.charAt(i++));
|
56
|
+
enc2 = this._keyStr.indexOf(input.charAt(i++));
|
57
|
+
enc3 = this._keyStr.indexOf(input.charAt(i++));
|
58
|
+
enc4 = this._keyStr.indexOf(input.charAt(i++));
|
59
|
+
|
60
|
+
chr1 = (enc1 << 2) | (enc2 >> 4);
|
61
|
+
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
62
|
+
chr3 = ((enc3 & 3) << 6) | enc4;
|
63
|
+
|
64
|
+
output = output + String.fromCharCode(chr1);
|
65
|
+
|
66
|
+
if (enc3 != 64) {
|
67
|
+
output = output + String.fromCharCode(chr2);
|
68
|
+
}
|
69
|
+
if (enc4 != 64) {
|
70
|
+
output = output + String.fromCharCode(chr3);
|
71
|
+
}
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
output = Base64._utf8_decode(output);
|
76
|
+
|
77
|
+
return output;
|
78
|
+
|
79
|
+
},
|
80
|
+
|
81
|
+
// private method for UTF-8 encoding
|
82
|
+
_utf8_encode : function(string) {
|
83
|
+
string = string.replace(/\r\n/g, "\n");
|
84
|
+
var utftext = "";
|
85
|
+
|
86
|
+
for (var n = 0; n < string.length; n++) {
|
87
|
+
|
88
|
+
var c = string.charCodeAt(n);
|
89
|
+
|
90
|
+
if (c < 128) {
|
91
|
+
utftext += String.fromCharCode(c);
|
92
|
+
} else if ((c > 127) && (c < 2048)) {
|
93
|
+
utftext += String.fromCharCode((c >> 6) | 192);
|
94
|
+
utftext += String.fromCharCode((c & 63) | 128);
|
95
|
+
} else {
|
96
|
+
utftext += String.fromCharCode((c >> 12) | 224);
|
97
|
+
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
98
|
+
utftext += String.fromCharCode((c & 63) | 128);
|
99
|
+
}
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
return utftext;
|
104
|
+
},
|
105
|
+
|
106
|
+
// private method for UTF-8 decoding
|
107
|
+
_utf8_decode : function(utftext) {
|
108
|
+
var string = "";
|
109
|
+
var i = 0;
|
110
|
+
var c = c1 = c2 = 0;
|
111
|
+
|
112
|
+
while (i < utftext.length) {
|
113
|
+
|
114
|
+
c = utftext.charCodeAt(i);
|
115
|
+
|
116
|
+
if (c < 128) {
|
117
|
+
string += String.fromCharCode(c);
|
118
|
+
i++;
|
119
|
+
} else if ((c > 191) && (c < 224)) {
|
120
|
+
c2 = utftext.charCodeAt(i + 1);
|
121
|
+
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
|
122
|
+
i += 2;
|
123
|
+
} else {
|
124
|
+
c2 = utftext.charCodeAt(i + 1);
|
125
|
+
c3 = utftext.charCodeAt(i + 2);
|
126
|
+
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
|
127
|
+
i += 3;
|
128
|
+
}
|
129
|
+
|
130
|
+
}
|
131
|
+
|
132
|
+
return string;
|
133
|
+
}
|
134
|
+
};
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'git'
|
2
|
+
|
3
|
+
namespace :swagger_ui do
|
4
|
+
namespace :dist do
|
5
|
+
desc "Update Swagger-UI from wordnik/swagger-ui."
|
6
|
+
task :update do
|
7
|
+
Dir.mktmpdir 'swagger-ui' do |dir|
|
8
|
+
puts "Cloning into #{dir} ..."
|
9
|
+
# clone wordnik/swagger-ui
|
10
|
+
Git.clone 'git@github.com:wordnik/swagger-ui.git', 'swagger-ui', path: dir
|
11
|
+
# prune local files
|
12
|
+
root = File.expand_path '../../..', __FILE__
|
13
|
+
puts "Removing files from #{root} ..."
|
14
|
+
repo = Git.open root
|
15
|
+
# Javascripts
|
16
|
+
puts "Copying Javascripts ..."
|
17
|
+
FileUtils.rm_r "#{root}/app/assets/javascripts/grape_swagger_rails"
|
18
|
+
FileUtils.cp_r "#{dir}/swagger-ui/dist/lib", "#{root}/app/assets/javascripts"
|
19
|
+
FileUtils.mv "#{root}/app/assets/javascripts/lib", "#{root}/app/assets/javascripts/grape_swagger_rails"
|
20
|
+
FileUtils.cp_r Dir.glob("#{dir}/swagger-ui/dist/swagger-ui.min.js"), "#{root}/app/assets/javascripts/grape_swagger_rails"
|
21
|
+
FileUtils.cp Dir.glob("#{root}/lib/javascripts/*.js"), "#{root}/app/assets/javascripts/grape_swagger_rails"
|
22
|
+
# Generate application.js
|
23
|
+
JAVASCRIPT_FILES = [
|
24
|
+
'shred.bundle.js',
|
25
|
+
'jquery-1.8.0.min.js',
|
26
|
+
'jquery.slideto.min.js',
|
27
|
+
'jquery.wiggle.min.js',
|
28
|
+
'jquery.ba-bbq.min.js',
|
29
|
+
'handlebars-1.0.0.js',
|
30
|
+
'underscore-min.js',
|
31
|
+
'backbone-min.js',
|
32
|
+
'swagger.js',
|
33
|
+
'swagger-ui.min.js',
|
34
|
+
'highlight.7.3.pack.js',
|
35
|
+
'swagger-oauth.js',
|
36
|
+
'base64.js'
|
37
|
+
]
|
38
|
+
javascript_files = Dir["#{root}/app/assets/javascripts/grape_swagger_rails/*.js"].map { |f|
|
39
|
+
f.split('/').last
|
40
|
+
} - ['application.js']
|
41
|
+
(javascript_files - JAVASCRIPT_FILES).each do |filename|
|
42
|
+
puts "WARNING: add #{filename} to swagger_ui.rake"
|
43
|
+
end
|
44
|
+
(JAVASCRIPT_FILES - javascript_files).each do |filename|
|
45
|
+
puts "WARNING: remove #{filename} from swagger_ui.rake"
|
46
|
+
end
|
47
|
+
File.open "#{root}/app/assets/javascripts/grape_swagger_rails/application.js", "w+" do |file|
|
48
|
+
JAVASCRIPT_FILES.each do |filename|
|
49
|
+
file.write "//= require ./#{File.basename(filename, '.*')}\n"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
# Stylesheets
|
53
|
+
puts "Copying Stylesheets ..."
|
54
|
+
repo.remove 'app/assets/stylesheets/grape_swagger_rails', recursive: true
|
55
|
+
FileUtils.mkdir_p "#{root}/app/assets/stylesheets/grape_swagger_rails"
|
56
|
+
FileUtils.cp_r Dir.glob("#{dir}/swagger-ui/dist/css/**/*"), "#{root}/app/assets/stylesheets/grape_swagger_rails"
|
57
|
+
repo.add 'app/assets/stylesheets/grape_swagger_rails'
|
58
|
+
# Generate application.js
|
59
|
+
CSS_FILES = [
|
60
|
+
'reset.css',
|
61
|
+
'screen.css'
|
62
|
+
]
|
63
|
+
css_files = Dir["#{root}/app/assets/stylesheets/grape_swagger_rails/*.css"].map { |f|
|
64
|
+
f.split('/').last
|
65
|
+
} - ['application.css']
|
66
|
+
(css_files - CSS_FILES).each do |filename|
|
67
|
+
puts "WARNING: add #{filename} to swagger_ui.rake"
|
68
|
+
end
|
69
|
+
(CSS_FILES - css_files).each do |filename|
|
70
|
+
puts "WARNING: remove #{filename} from swagger_ui.rake"
|
71
|
+
end
|
72
|
+
# rewrite screen.css into screen.css.erb with dynamic image paths
|
73
|
+
File.open "#{root}/app/assets/stylesheets/grape_swagger_rails/screen.css.erb", "w+" do |file|
|
74
|
+
contents = File.read "#{root}/app/assets/stylesheets/grape_swagger_rails/screen.css"
|
75
|
+
contents.gsub! /url\((\'*).*\/(?<filename>[\w\.]*)(\'*)\)/ do |match|
|
76
|
+
"url(<%= image_path('grape_swagger_rails/#{$~[:filename]}') %>)"
|
77
|
+
end
|
78
|
+
file.write contents
|
79
|
+
FileUtils.rm "#{root}/app/assets/stylesheets/grape_swagger_rails/screen.css"
|
80
|
+
end
|
81
|
+
File.open "#{root}/app/assets/stylesheets/grape_swagger_rails/application.css", "w+" do |file|
|
82
|
+
file.write "/*\n"
|
83
|
+
CSS_FILES.each do |filename|
|
84
|
+
file.write "*= require ./#{File.basename(filename, '.*')}\n"
|
85
|
+
end
|
86
|
+
file.write "*= require_self\n"
|
87
|
+
file.write "*/\n"
|
88
|
+
end
|
89
|
+
# Images
|
90
|
+
puts "Copying Images ..."
|
91
|
+
repo.remove 'app/assets/images/grape_swagger_rails', recursive: true
|
92
|
+
FileUtils.mkdir_p "#{root}/app/assets/images/grape_swagger_rails"
|
93
|
+
FileUtils.cp_r Dir.glob("#{dir}/swagger-ui/dist/images/**/*"), "#{root}/app/assets/images/grape_swagger_rails"
|
94
|
+
repo.add 'app/assets'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-journal
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*.log
|
16
|
+
/tmp
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
class API < Grape::API
|
2
|
+
format :json
|
3
|
+
prefix 'api'
|
4
|
+
|
5
|
+
namespace :foos do
|
6
|
+
desc 'Get foos.'
|
7
|
+
get do
|
8
|
+
[{ id: 1, name: 'Foo' }]
|
9
|
+
end
|
10
|
+
|
11
|
+
desc 'Get a foo.'
|
12
|
+
params do
|
13
|
+
requires :id, type: String, desc: 'Foo id.'
|
14
|
+
end
|
15
|
+
get :id do
|
16
|
+
{ id: 1, name: 'Foo' }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'Get headers.'
|
21
|
+
get '/headers' do
|
22
|
+
request.headers.as_json
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'Get params.'
|
26
|
+
get '/params' do
|
27
|
+
request.params.as_json
|
28
|
+
end
|
29
|
+
|
30
|
+
add_swagger_documentation
|
31
|
+
end
|