apipie-rails 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +9 -0
- data/app/views/apipie/apipies/_disqus.html.erb +1 -1
- data/lib/apipie/application.rb +15 -1
- data/lib/apipie/resource_description.rb +7 -0
- data/lib/apipie/version.rb +1 -1
- data/spec/controllers/apipies_controller_spec.rb +36 -1
- metadata +136 -141
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
Changelog
|
3
3
|
===========
|
4
4
|
|
5
|
+
v0.2.6
|
6
|
+
------
|
7
|
+
|
8
|
+
* better handling on cases where resource/method is not found when cache is turned off
|
9
|
+
[#284](https://github.com/Apipie/apipie-rails/pull/284) [@iNecas][]
|
10
|
+
* fix disqus integration
|
11
|
+
[#281](https://github.com/Apipie/apipie-rails/pull/281) [@RajRoR][]
|
12
|
+
|
5
13
|
v0.2.5
|
6
14
|
------
|
7
15
|
|
@@ -210,3 +218,4 @@ v0.0.15
|
|
210
218
|
[@mourad-ifeelgoods]: https://github.com/mourad-ifeelgoods
|
211
219
|
[@domcleal]: https://github.com/domcleal
|
212
220
|
[@dustint-rh]: https://github.com/dustint-rh
|
221
|
+
[@RajRoR]: https://github.com/RajRoR
|
@@ -10,4 +10,4 @@
|
|
10
10
|
<noscript><%= t('apipie.enable_javascript_html', :comments_href => link_to(
|
11
11
|
t('apipie.comments_powered_by_disqus', :disqus => 'Disqus'),
|
12
12
|
"http://disqus.com/?ref_noscript")) %></noscript>
|
13
|
-
<a href="http://disqus.com" class="dsq-brlink"><%= t('apipie.comments_powered_by_disqus', :disqus => "<span class=
|
13
|
+
<a href="http://disqus.com" class="dsq-brlink"><%= t('apipie.comments_powered_by_disqus', :disqus => "<span class='logo-disqus'>Disqus</span>") %></a>
|
data/lib/apipie/application.rb
CHANGED
@@ -216,7 +216,7 @@ module Apipie
|
|
216
216
|
|
217
217
|
def to_json(version, resource_name, method_name, lang)
|
218
218
|
|
219
|
-
return unless
|
219
|
+
return unless valid_search_args?(version, resource_name, method_name)
|
220
220
|
|
221
221
|
_resources = if resource_name.blank?
|
222
222
|
# take just resources which have some methods because
|
@@ -324,6 +324,20 @@ module Apipie
|
|
324
324
|
|
325
325
|
private
|
326
326
|
|
327
|
+
# Make sure that the version/resource_name/method_name are valid combination
|
328
|
+
# resource_name and method_name can be nil
|
329
|
+
def valid_search_args?(version, resource_name, method_name)
|
330
|
+
return false unless self.resource_descriptions.has_key?(version)
|
331
|
+
if resource_name
|
332
|
+
return false unless self.resource_descriptions[version].has_key?(resource_name)
|
333
|
+
if method_name
|
334
|
+
resource_description = self.resource_descriptions[version][resource_name]
|
335
|
+
return false unless resource_description.valid_method_name?(method_name)
|
336
|
+
end
|
337
|
+
end
|
338
|
+
return true
|
339
|
+
end
|
340
|
+
|
327
341
|
def version_prefix(klass)
|
328
342
|
version = controller_versions(klass).first
|
329
343
|
base_url = get_base_url(version)
|
@@ -81,7 +81,14 @@ module Apipie
|
|
81
81
|
|
82
82
|
def api_url; "#{Apipie.api_base_url(_version)}#{@_path}"; end
|
83
83
|
|
84
|
+
def valid_method_name?(method_name)
|
85
|
+
@_methods.keys.map(&:to_s).include?(method_name.to_s)
|
86
|
+
end
|
87
|
+
|
84
88
|
def to_json(method_name = nil, lang = nil)
|
89
|
+
if method_name && !valid_method_name?(method_name)
|
90
|
+
raise "Method #{method_name} not found for resource #{_name}"
|
91
|
+
end
|
85
92
|
|
86
93
|
methods = if method_name.blank?
|
87
94
|
@_methods.collect { |key, method_description| method_description.to_json(lang) }
|
data/lib/apipie/version.rb
CHANGED
@@ -5,12 +5,47 @@ describe Apipie::ApipiesController do
|
|
5
5
|
|
6
6
|
describe "GET index" do
|
7
7
|
|
8
|
-
it "
|
8
|
+
it "succeeds on index" do
|
9
9
|
get :index
|
10
10
|
|
11
11
|
assert_response :success
|
12
12
|
end
|
13
13
|
|
14
|
+
it "succeeds on version details" do
|
15
|
+
get :index, :version => "2.0"
|
16
|
+
|
17
|
+
assert_response :success
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns not_found on wrong version" do
|
21
|
+
get :index, :version => "wrong_version"
|
22
|
+
|
23
|
+
assert_response :not_found
|
24
|
+
end
|
25
|
+
|
26
|
+
it "succeeds on resource details" do
|
27
|
+
get :index, :version => "2.0", :resource => "architectures"
|
28
|
+
|
29
|
+
assert_response :success
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns not_found on wrong resource" do
|
33
|
+
get :index, :version => "2.0", :resource => "wrong_resource"
|
34
|
+
|
35
|
+
assert_response :not_found
|
36
|
+
end
|
37
|
+
|
38
|
+
it "succeeds on method details" do
|
39
|
+
get :index, :version => "2.0", :resource => "architectures", :method => "index"
|
40
|
+
|
41
|
+
assert_response :success
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns not_found on wrong method" do
|
45
|
+
get :index, :version => "2.0", :resource => "architectures", :method => "wrong_method"
|
46
|
+
|
47
|
+
assert_response :not_found
|
48
|
+
end
|
14
49
|
end
|
15
50
|
|
16
51
|
describe "reload_controllers" do
|
metadata
CHANGED
@@ -1,165 +1,169 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: apipie-rails
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.6
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 5
|
10
|
-
version: 0.2.5
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Pavel Pokorny
|
14
9
|
- Ivan Necas
|
15
10
|
autorequire:
|
16
11
|
bindir: bin
|
17
12
|
cert_chain: []
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
dependencies:
|
22
|
-
- !ruby/object:Gem::Dependency
|
13
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
23
16
|
name: rails
|
24
|
-
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
26
18
|
none: false
|
27
|
-
requirements:
|
28
|
-
- -
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
hash: 19
|
31
|
-
segments:
|
32
|
-
- 3
|
33
|
-
- 0
|
34
|
-
- 10
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
35
22
|
version: 3.0.10
|
36
23
|
type: :development
|
37
|
-
version_requirements: *id001
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: json
|
40
24
|
prerelease: false
|
41
|
-
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 3.0.10
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: json
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
42
34
|
none: false
|
43
|
-
requirements:
|
44
|
-
- -
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
|
47
|
-
segments:
|
48
|
-
- 0
|
49
|
-
version: "0"
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
50
39
|
type: :runtime
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: rspec-rails
|
54
40
|
prerelease: false
|
55
|
-
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec-rails
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
56
50
|
none: false
|
57
|
-
requirements:
|
51
|
+
requirements:
|
58
52
|
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
hash: 51
|
61
|
-
segments:
|
62
|
-
- 2
|
63
|
-
- 14
|
64
|
-
- 2
|
53
|
+
- !ruby/object:Gem::Version
|
65
54
|
version: 2.14.2
|
66
55
|
type: :development
|
67
|
-
version_requirements: *id003
|
68
|
-
- !ruby/object:Gem::Dependency
|
69
|
-
name: sqlite3
|
70
56
|
prerelease: false
|
71
|
-
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
72
58
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.14.2
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: sqlite3
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
80
71
|
type: :development
|
81
|
-
version_requirements: *id004
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: minitest
|
84
72
|
prerelease: false
|
85
|
-
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: minitest
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
86
82
|
none: false
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
segments:
|
92
|
-
- 0
|
93
|
-
version: "0"
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
94
87
|
type: :development
|
95
|
-
version_requirements: *id005
|
96
|
-
- !ruby/object:Gem::Dependency
|
97
|
-
name: maruku
|
98
88
|
prerelease: false
|
99
|
-
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: maruku
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
100
98
|
none: false
|
101
|
-
requirements:
|
102
|
-
- -
|
103
|
-
- !ruby/object:Gem::Version
|
104
|
-
|
105
|
-
segments:
|
106
|
-
- 0
|
107
|
-
version: "0"
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
108
103
|
type: :development
|
109
|
-
version_requirements: *id006
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: RedCloth
|
112
104
|
prerelease: false
|
113
|
-
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: RedCloth
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
114
|
none: false
|
115
|
-
requirements:
|
116
|
-
- -
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
|
119
|
-
segments:
|
120
|
-
- 0
|
121
|
-
version: "0"
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
122
119
|
type: :development
|
123
|
-
version_requirements: *id007
|
124
|
-
- !ruby/object:Gem::Dependency
|
125
|
-
name: rake
|
126
120
|
prerelease: false
|
127
|
-
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
122
|
none: false
|
129
|
-
requirements:
|
130
|
-
- -
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: rake
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
136
135
|
type: :development
|
137
|
-
version_requirements: *id008
|
138
|
-
- !ruby/object:Gem::Dependency
|
139
|
-
name: rdoc
|
140
136
|
prerelease: false
|
141
|
-
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
142
138
|
none: false
|
143
|
-
requirements:
|
144
|
-
- -
|
145
|
-
- !ruby/object:Gem::Version
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
name: rdoc
|
145
|
+
requirement: !ruby/object:Gem::Requirement
|
146
|
+
none: false
|
147
|
+
requirements:
|
148
|
+
- - ! '>='
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
150
151
|
type: :development
|
151
|
-
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
none: false
|
155
|
+
requirements:
|
156
|
+
- - ! '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
152
159
|
description: Rails REST API documentation tool
|
153
|
-
email:
|
160
|
+
email:
|
154
161
|
- pajkycz@gmail.com
|
155
162
|
- inecas@redhat.com
|
156
163
|
executables: []
|
157
|
-
|
158
164
|
extensions: []
|
159
|
-
|
160
165
|
extra_rdoc_files: []
|
161
|
-
|
162
|
-
files:
|
166
|
+
files:
|
163
167
|
- .gitignore
|
164
168
|
- .rspec
|
165
169
|
- .travis.yml
|
@@ -297,41 +301,31 @@ files:
|
|
297
301
|
- spec/lib/validators/array_validator_spec.rb
|
298
302
|
- spec/spec_helper.rb
|
299
303
|
- spec/support/rake.rb
|
300
|
-
has_rdoc: true
|
301
304
|
homepage: http://github.com/Pajk/apipie-rails
|
302
305
|
licenses: []
|
303
|
-
|
304
306
|
post_install_message:
|
305
307
|
rdoc_options: []
|
306
|
-
|
307
|
-
require_paths:
|
308
|
+
require_paths:
|
308
309
|
- lib
|
309
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
310
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
310
311
|
none: false
|
311
|
-
requirements:
|
312
|
-
- -
|
313
|
-
- !ruby/object:Gem::Version
|
314
|
-
|
315
|
-
|
316
|
-
- 0
|
317
|
-
version: "0"
|
318
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
312
|
+
requirements:
|
313
|
+
- - ! '>='
|
314
|
+
- !ruby/object:Gem::Version
|
315
|
+
version: '0'
|
316
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
319
317
|
none: false
|
320
|
-
requirements:
|
321
|
-
- -
|
322
|
-
- !ruby/object:Gem::Version
|
323
|
-
|
324
|
-
segments:
|
325
|
-
- 0
|
326
|
-
version: "0"
|
318
|
+
requirements:
|
319
|
+
- - ! '>='
|
320
|
+
- !ruby/object:Gem::Version
|
321
|
+
version: '0'
|
327
322
|
requirements: []
|
328
|
-
|
329
323
|
rubyforge_project:
|
330
|
-
rubygems_version: 1.
|
324
|
+
rubygems_version: 1.8.23
|
331
325
|
signing_key:
|
332
326
|
specification_version: 3
|
333
327
|
summary: Rails REST API documentation tool
|
334
|
-
test_files:
|
328
|
+
test_files:
|
335
329
|
- spec/controllers/api/v1/architectures_controller_spec.rb
|
336
330
|
- spec/controllers/api/v2/architectures_controller_spec.rb
|
337
331
|
- spec/controllers/api/v2/nested/resources_controller_spec.rb
|
@@ -396,3 +390,4 @@ test_files:
|
|
396
390
|
- spec/lib/validators/array_validator_spec.rb
|
397
391
|
- spec/spec_helper.rb
|
398
392
|
- spec/support/rake.rb
|
393
|
+
has_rdoc:
|