apipie-rails 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +8 -0
- data/README.rst +2 -2
- data/lib/apipie/application.rb +2 -2
- data/lib/apipie/dsl_definition.rb +1 -14
- data/lib/apipie/method_description.rb +18 -2
- data/lib/apipie/static_dispatcher.rb +2 -2
- data/lib/apipie/version.rb +1 -1
- data/spec/controllers/concerns_controller_spec.rb +1 -1
- data/spec/dummy/app/controllers/concerns/sample_controller.rb +1 -1
- metadata +2 -2
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
Changelog
|
|
3
3
|
===========
|
|
4
4
|
|
|
5
|
+
v0.3.1
|
|
6
|
+
------
|
|
7
|
+
|
|
8
|
+
* Support for ``api!`` keyword in concerns
|
|
9
|
+
[#322](https://github.com/Apipie/apipie-rails/pull/322) [@iNecas][]
|
|
10
|
+
* More explicit ordering of the static dispatcher middleware
|
|
11
|
+
[#315](https://github.com/Apipie/apipie-rails/pull/315) [@iNecas][]
|
|
12
|
+
|
|
5
13
|
v0.3.0
|
|
6
14
|
------
|
|
7
15
|
This should be a backward compatible release. However, the number of new
|
data/README.rst
CHANGED
|
@@ -425,7 +425,7 @@ There are some default substitutions available:
|
|
|
425
425
|
|
|
426
426
|
:controller_path
|
|
427
427
|
value of ``controller.controller_path``, e.g. ``api/users`` for
|
|
428
|
-
``Api::UsersController``
|
|
428
|
+
``Api::UsersController``. Only if not using the ``api!`` keyword.
|
|
429
429
|
|
|
430
430
|
:resource_id
|
|
431
431
|
Apipie identifier of the resource, e.g. ``users`` for
|
|
@@ -445,7 +445,7 @@ Example
|
|
|
445
445
|
# ...
|
|
446
446
|
end
|
|
447
447
|
|
|
448
|
-
api
|
|
448
|
+
api! 'Show a :resource'
|
|
449
449
|
def show
|
|
450
450
|
# ...
|
|
451
451
|
end
|
data/lib/apipie/application.rb
CHANGED
|
@@ -9,8 +9,8 @@ module Apipie
|
|
|
9
9
|
class Application
|
|
10
10
|
# we need engine just for serving static assets
|
|
11
11
|
class Engine < Rails::Engine
|
|
12
|
-
initializer "static assets" do |app|
|
|
13
|
-
app.middleware.use ::Apipie::StaticDispatcher, "#{root}/app/public"
|
|
12
|
+
initializer "static assets", :before => :build_middleware_stack do |app|
|
|
13
|
+
app.middleware.use ::Apipie::StaticDispatcher, "#{root}/app/public"
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -376,20 +376,7 @@ module Apipie
|
|
|
376
376
|
super
|
|
377
377
|
return if !Apipie.active_dsl? || !_apipie_dsl_data[:api]
|
|
378
378
|
|
|
379
|
-
if _apipie_dsl_data[:api_from_routes]
|
|
380
|
-
desc = _apipie_dsl_data[:api_from_routes][:desc]
|
|
381
|
-
options = _apipie_dsl_data[:api_from_routes][:options]
|
|
382
|
-
|
|
383
|
-
api_from_routes = Apipie.routes_for_action(self, method_name, {:desc => desc, :options => options}).map do |route_info|
|
|
384
|
-
[route_info[:verb],
|
|
385
|
-
route_info[:path],
|
|
386
|
-
route_info[:desc],
|
|
387
|
-
(route_info[:options] || {}).merge(:from_routes => true)]
|
|
388
|
-
end
|
|
389
|
-
_apipie_dsl_data[:api_args].concat(api_from_routes)
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
return if _apipie_dsl_data[:api_args].blank?
|
|
379
|
+
return if _apipie_dsl_data[:api_args].blank? && _apipie_dsl_data[:api_from_routes].blank?
|
|
393
380
|
|
|
394
381
|
# remove method description if exists and create new one
|
|
395
382
|
Apipie.remove_method_description(self, _apipie_dsl_data[:api_versions], method_name)
|
|
@@ -23,8 +23,7 @@ module Apipie
|
|
|
23
23
|
@method = method.to_s
|
|
24
24
|
@resource = resource
|
|
25
25
|
@from_concern = dsl_data[:from_concern]
|
|
26
|
-
|
|
27
|
-
@apis = dsl_data[:api_args].map do |mthd, path, desc, opts|
|
|
26
|
+
@apis = api_data(dsl_data).map do |mthd, path, desc, opts|
|
|
28
27
|
MethodDescription::Api.new(mthd, concern_subst(path), concern_subst(desc), opts)
|
|
29
28
|
end
|
|
30
29
|
|
|
@@ -154,6 +153,23 @@ module Apipie
|
|
|
154
153
|
|
|
155
154
|
private
|
|
156
155
|
|
|
156
|
+
def api_data(dsl_data)
|
|
157
|
+
ret = dsl_data[:api_args].dup
|
|
158
|
+
if dsl_data[:api_from_routes]
|
|
159
|
+
desc = dsl_data[:api_from_routes][:desc]
|
|
160
|
+
options = dsl_data[:api_from_routes][:options]
|
|
161
|
+
|
|
162
|
+
api_from_routes = Apipie.routes_for_action(resource.controller, method, {:desc => desc, :options => options}).map do |route_info|
|
|
163
|
+
[route_info[:verb],
|
|
164
|
+
route_info[:path],
|
|
165
|
+
route_info[:desc],
|
|
166
|
+
(route_info[:options] || {}).merge(:from_routes => true)]
|
|
167
|
+
end
|
|
168
|
+
ret.concat(api_from_routes)
|
|
169
|
+
end
|
|
170
|
+
ret
|
|
171
|
+
end
|
|
172
|
+
|
|
157
173
|
def merge_params(params, new_params)
|
|
158
174
|
new_param_names = Set.new(new_params.map(&:name))
|
|
159
175
|
params.delete_if { |p| new_param_names.include?(p.name) }
|
|
@@ -45,13 +45,13 @@ module Apipie
|
|
|
45
45
|
class StaticDispatcher
|
|
46
46
|
# Dispatches the static files. Similar to ActionDispatch::Static, but
|
|
47
47
|
# it supports different baseurl configurations
|
|
48
|
-
def initialize(app, path
|
|
48
|
+
def initialize(app, path)
|
|
49
49
|
@app = app
|
|
50
|
-
@baseurl = baseurl
|
|
51
50
|
@file_handler = Apipie::FileHandler.new(path)
|
|
52
51
|
end
|
|
53
52
|
|
|
54
53
|
def call(env)
|
|
54
|
+
@baseurl ||= Apipie.configuration.doc_base_url
|
|
55
55
|
case env['REQUEST_METHOD']
|
|
56
56
|
when 'GET', 'HEAD'
|
|
57
57
|
path = env['PATH_INFO'].sub("#{@baseurl}/","/apipie/").chomp('/')
|
data/lib/apipie/version.rb
CHANGED
|
@@ -23,7 +23,7 @@ describe ConcernsController do
|
|
|
23
23
|
|
|
24
24
|
it "replaces a placeholder doc specified in concern with a real path" do
|
|
25
25
|
path = Apipie["concern_resources#index"].apis.first.path
|
|
26
|
-
path.should == '/concerns'
|
|
26
|
+
path.should == '/api/concerns'
|
|
27
27
|
|
|
28
28
|
path = Apipie["concern_resources#show"].apis.first.path
|
|
29
29
|
path.should == '/concern_resources/:id'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: apipie-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2015-01-
|
|
13
|
+
date: 2015-01-25 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: rails
|