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.
@@ -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
- ", '1.0'
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::RailsFormatter
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.reload_documentation if Apipie.configuration.reload_controllers?
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
 
@@ -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
- reload_documentation if available_versions == []
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
@@ -1,3 +1,3 @@
1
1
  module Apipie
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.2'
3
3
  end
@@ -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/*.rb"
6
+ config.api_controllers_matcher = "#{Rails.root}/app/controllers/**/*.rb"
7
7
  end
@@ -26,4 +26,5 @@ Dummy::Application.routes.draw do
26
26
  apipie
27
27
  end
28
28
  root :to => 'apipie/apipies#index'
29
+ match '(/)*path' => redirect('http://www.example.com'), :via => :all
29
30
  end
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.1
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-01-25 00:00:00.000000000 Z
13
+ date: 2015-03-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails