apipie-rails 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +15 -0
- data/README.rst +9 -3
- data/app/controllers/apipie/apipies_controller.rb +2 -1
- data/lib/apipie/application.rb +12 -4
- data/lib/apipie/extractor/recorder.rb +1 -1
- data/lib/apipie/version.rb +1 -1
- data/lib/generators/apipie/install/templates/initializer.rb.erb +1 -1
- data/spec/dummy/config/routes.rb +1 -0
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
Changelog
|
3
3
|
===========
|
4
4
|
|
5
|
+
v0.3.2
|
6
|
+
------
|
7
|
+
|
8
|
+
* PATCH support for examples recording
|
9
|
+
[#332](https://github.com/Apipie/apipie-rails/pull/332) [@akenger][]
|
10
|
+
* Recursively search for API controllers by default for new projects
|
11
|
+
[#333](https://github.com/Apipie/apipie-rails/pull/333) [@baweaver][]
|
12
|
+
* Handling recursive route definitions with `api!` keyword
|
13
|
+
[#338](https://github.com/Apipie/apipie-rails/pull/338) [@stormsilver][]
|
14
|
+
* Support for eager-loaded controllers
|
15
|
+
[#329](https://github.com/Apipie/apipie-rails/pull/329) [@mtparet][]
|
16
|
+
|
5
17
|
v0.3.1
|
6
18
|
------
|
7
19
|
|
@@ -259,3 +271,6 @@ v0.0.15
|
|
259
271
|
[@bradrf]: https://github.com/bradrf
|
260
272
|
[@dprice-fiksu]: https://github.com/dprice-fiksu
|
261
273
|
[@burnettk]: https://github.com/burnettk
|
274
|
+
[@akenger]: https://github.com/akenger
|
275
|
+
[@baweaver]: https://github.com/baweaver
|
276
|
+
[@stormsilver]: https://github.com/stormsilver
|
data/README.rst
CHANGED
@@ -616,10 +616,10 @@ Example:
|
|
616
616
|
config.reload_controllers = Rails.env.development?
|
617
617
|
config.api_controllers_matcher = File.join(Rails.root, "app", "controllers", "**","*.rb")
|
618
618
|
config.api_routes = Rails.application.routes
|
619
|
-
config.app_info = "
|
619
|
+
config.app_info["1.0"] = "
|
620
620
|
This is where you can inform user about your application and API
|
621
621
|
in general.
|
622
|
-
"
|
622
|
+
"
|
623
623
|
config.authenticate = Proc.new do
|
624
624
|
authenticate_or_request_with_http_basic do |username, password|
|
625
625
|
username == "test" && password == "supersecretpassword"
|
@@ -649,7 +649,7 @@ option, like this:
|
|
649
649
|
|
650
650
|
.. code:: ruby
|
651
651
|
|
652
|
-
class MyFormatter < Apipie::
|
652
|
+
class MyFormatter < Apipie::RoutesFormatter
|
653
653
|
def format_path(route)
|
654
654
|
super.gsub(/\(.*?\)/, '').gsub('//','') # hide all implicit parameters
|
655
655
|
end
|
@@ -1241,6 +1241,12 @@ And then configure RSpec in this way:
|
|
1241
1241
|
This way, when running in recording mode, only the tests that have been marked with the
|
1242
1242
|
``:show_in_doc`` metadata will be run, and hence only those will be used as examples.
|
1243
1243
|
|
1244
|
+
Caveats
|
1245
|
+
-------
|
1246
|
+
|
1247
|
+
Make sure to enable ``config.render_views`` in your ``config/rails_helper.rb`` or
|
1248
|
+
``config/spec_helper.rb`` if you're using jbuilder, or you will get back empty results
|
1249
|
+
|
1244
1250
|
====================
|
1245
1251
|
Bindings Generator
|
1246
1252
|
====================
|
@@ -26,7 +26,8 @@ module Apipie
|
|
26
26
|
|
27
27
|
@language = get_language
|
28
28
|
|
29
|
-
Apipie.
|
29
|
+
Apipie.load_documentation if Apipie.configuration.reload_controllers? || (Rails.version.to_i >= 4.0 && !Rails.application.config.eager_load)
|
30
|
+
|
30
31
|
I18n.locale = @language
|
31
32
|
@doc = Apipie.to_json(params[:version], params[:resource], params[:method], @language)
|
32
33
|
|
data/lib/apipie/application.rb
CHANGED
@@ -53,11 +53,12 @@ module Apipie
|
|
53
53
|
|
54
54
|
# the app might be nested when using contraints, namespaces etc.
|
55
55
|
# this method does in depth search for the route controller
|
56
|
-
def route_app_controller(app, route)
|
56
|
+
def route_app_controller(app, route, visited_apps = [])
|
57
|
+
visited_apps << app
|
57
58
|
if app.respond_to?(:controller)
|
58
59
|
return app.controller(route.defaults)
|
59
|
-
elsif app.respond_to?(:app)
|
60
|
-
return route_app_controller(app.app, route)
|
60
|
+
elsif app.respond_to?(:app) && !visited_apps.include?(app.app)
|
61
|
+
return route_app_controller(app.app, route, visited_apps)
|
61
62
|
end
|
62
63
|
rescue ActionController::RoutingError
|
63
64
|
# some errors in the routes will not stop us here: just ignoring
|
@@ -305,6 +306,13 @@ module Apipie
|
|
305
306
|
locale = old_locale
|
306
307
|
end
|
307
308
|
|
309
|
+
def load_documentation
|
310
|
+
if !@documentation_loaded || Apipie.configuration.reload_controllers?
|
311
|
+
Apipie.reload_documentation
|
312
|
+
@documentation_loaded = true
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
308
316
|
def compute_checksum
|
309
317
|
if Apipie.configuration.use_cache?
|
310
318
|
file_base = File.join(Apipie.configuration.cache_dir, Apipie.configuration.doc_base_url)
|
@@ -313,7 +321,7 @@ module Apipie
|
|
313
321
|
all_docs[File.basename(f, '.json')] = JSON.parse(File.read(f))
|
314
322
|
end
|
315
323
|
else
|
316
|
-
|
324
|
+
load_documentation if available_versions == []
|
317
325
|
all_docs = Apipie.available_versions.inject({}) do |all, version|
|
318
326
|
all.update(version => Apipie.to_json(version))
|
319
327
|
end
|
@@ -38,7 +38,7 @@ module Apipie
|
|
38
38
|
@verb = request.request_method.to_sym
|
39
39
|
@path = request.path
|
40
40
|
@params = request.request_parameters
|
41
|
-
if [:POST, :PUT].include?(@verb)
|
41
|
+
if [:POST, :PUT, :PATCH].include?(@verb)
|
42
42
|
@request_data = @params
|
43
43
|
else
|
44
44
|
@query = request.query_string
|
data/lib/apipie/version.rb
CHANGED
@@ -3,5 +3,5 @@ Apipie.configure do |config|
|
|
3
3
|
config.api_base_url = "<%= options.api_path %>"
|
4
4
|
config.doc_base_url = "<%= options.route %>"
|
5
5
|
# where is your API defined?
|
6
|
-
config.api_controllers_matcher = "#{Rails.root}/app/controllers
|
6
|
+
config.api_controllers_matcher = "#{Rails.root}/app/controllers/**/*.rb"
|
7
7
|
end
|
data/spec/dummy/config/routes.rb
CHANGED
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.2
|
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-
|
13
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|