apipie-rails 1.0.0 → 1.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/config/locales/en.yml +1 -0
- data/lib/apipie/application.rb +18 -18
- data/lib/apipie/extractor/recorder.rb +3 -1
- data/lib/apipie/version.rb +1 -1
- data/spec/dummy/app/controllers/api/v2/architectures_controller.rb +2 -1
- data/spec/dummy/config/routes.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5beee9e3a891140602d1c9a962c9229cbeb60d7e289a95d62a48bfea39b396a9
|
4
|
+
data.tar.gz: 6f096bb6648692ceaa7a05fa095051a26c4bd176e062bf2ad794a9f3b5438261
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 27f57c84d3b692d40b84ee01740b960d10c9951bdf0e45d936079cd7dc0fac899a0ac90ccd229db6a164549c7238de6bb515f8102b7624342c406a775ee7cbfa
|
7
|
+
data.tar.gz: 4ee73961d9417cfa623d9d84b5dbf7a8afdfcd19afa86f43b72b807dce374a79b456c3c041d953cb5a31d3b5bb5ba4926ccfd6b2d751ee61e36e21fd0ec83776
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@
|
|
4
4
|
Also deleted the `Gemfile` that was now a broken symlink.
|
5
5
|
please use `export BUNDLE_GEMFILE='gemfiles/Gemfile.rails61'; bundle exec rspec` to run the test suite
|
6
6
|
|
7
|
+
## [v1.1.0](https://github.com/Apipie/apipie-rails/tree/v1.1.0) (2023-05-16)
|
8
|
+
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v1.0.0...v1.1.0)
|
9
|
+
* Improve performance of route detection [#870](https://github.com/Apipie/apipie-rails/pull/870) (Eric Hankins)
|
10
|
+
* Fix startup crash due to typo [#869](https://github.com/Apipie/apipie-rails/pull/869) (Eric Hankins)
|
11
|
+
* Skip parse body for pdf responses [#871](https://github.com/Apipie/apipie-rails/pull/871) (Juan Gomez)
|
12
|
+
* add missing 'returns' translation [#868](https://github.com/Apipie/apipie-rails/pull/868) (Anthony Robertson)
|
13
|
+
|
7
14
|
## [v1.0.0](https://github.com/Apipie/apipie-rails/tree/v1.0.0) (2023-04-26)
|
8
15
|
[Full Changelog](https://github.com/Apipie/apipie-rails/compare/v0.9.4...v1.0.0)
|
9
16
|
* Refactor Swagger generator [#816](https://github.com/Apipie/apipie-rails/pull/816) (Panos Dalitsouris)
|
data/config/locales/en.yml
CHANGED
data/lib/apipie/application.rb
CHANGED
@@ -26,14 +26,13 @@ module Apipie
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def rails_routes(route_set = nil, base_url = "")
|
29
|
-
if route_set.nil? && @
|
30
|
-
|
31
|
-
end
|
29
|
+
return @_rails_routes if route_set.nil? && @_rails_routes
|
30
|
+
|
32
31
|
route_set ||= Rails.application.routes
|
33
32
|
# ensure routes are loaded
|
34
33
|
Rails.application.reload_routes! unless Rails.application.routes.routes.any?
|
35
34
|
|
36
|
-
|
35
|
+
flattened_routes = []
|
37
36
|
|
38
37
|
route_set.routes.each do |route|
|
39
38
|
# route is_a ActionDispatch::Journey::Route
|
@@ -42,30 +41,30 @@ module Apipie
|
|
42
41
|
route_app = route.app.app
|
43
42
|
if route_app.respond_to?(:routes) && route_app.routes.is_a?(ActionDispatch::Routing::RouteSet)
|
44
43
|
# recursively go though the mounted engines
|
45
|
-
|
44
|
+
flattened_routes.concat(rails_routes(route_app.routes, File.join(base_url, route.path.spec.to_s)))
|
46
45
|
else
|
47
46
|
route.base_url = base_url
|
48
|
-
|
47
|
+
flattened_routes << route
|
49
48
|
end
|
50
49
|
end
|
51
50
|
|
52
|
-
@
|
51
|
+
@_rails_routes = flattened_routes
|
53
52
|
end
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
controller_name = "#{route.defaults[:controller]}_controller".camelize
|
60
|
-
controller_name.safe_constantize
|
54
|
+
def rails_routes_by_controller_and_action
|
55
|
+
@_rails_routes_by_controller_and_action = rails_routes.group_by do |route|
|
56
|
+
requirements = route.requirements
|
57
|
+
[requirements[:controller], requirements[:action]]
|
61
58
|
end
|
62
59
|
end
|
63
60
|
|
61
|
+
def clear_cached_routes!
|
62
|
+
@_rails_routes = nil
|
63
|
+
@_rails_routes_by_controller_and_action = nil
|
64
|
+
end
|
65
|
+
|
64
66
|
def routes_for_action(controller, method, args)
|
65
|
-
routes =
|
66
|
-
controller == route_app_controller(route.app, route) &&
|
67
|
-
method.to_s == route.defaults[:action]
|
68
|
-
end
|
67
|
+
routes = rails_routes_by_controller_and_action[[controller.name.underscore.chomp('_controller'), method.to_s]] || []
|
69
68
|
|
70
69
|
Apipie.configuration.routes_formatter.format_routes(routes, args)
|
71
70
|
end
|
@@ -227,7 +226,7 @@ module Apipie
|
|
227
226
|
|
228
227
|
def remove_method_description(resource, versions, method_name)
|
229
228
|
versions.each do |version|
|
230
|
-
resource =
|
229
|
+
resource = get_resource_id(resource)
|
231
230
|
if resource_description = get_resource_description("#{version}##{resource}")
|
232
231
|
resource_description.remove_method_description(method_name)
|
233
232
|
end
|
@@ -482,6 +481,7 @@ module Apipie
|
|
482
481
|
# as this would break loading of the controllers.
|
483
482
|
def rails_mark_classes_for_reload
|
484
483
|
unless Rails.application.config.cache_classes
|
484
|
+
clear_cached_routes!
|
485
485
|
Rails.application.reloader.reload!
|
486
486
|
init_env
|
487
487
|
reload_examples
|
data/lib/apipie/version.rb
CHANGED
data/spec/dummy/config/routes.rb
CHANGED
@@ -45,6 +45,12 @@ Dummy::Application.routes.draw do
|
|
45
45
|
get "/pets/returns_response_with_valid_array" => "pets#returns_response_with_valid_array"
|
46
46
|
get "/pets/returns_response_with_invalid_array" => "pets#returns_response_with_invalid_array"
|
47
47
|
get "/pets/undocumented_method" => "pets#undocumented_method"
|
48
|
+
|
49
|
+
# generate 1000 routes for testing performance of route matching used by api! method
|
50
|
+
# it's okay that these don't go anywhere real
|
51
|
+
1000.times do |i|
|
52
|
+
get "/api/v1/pets/#{i}" => "pets#{i}#show"
|
53
|
+
end
|
48
54
|
end
|
49
55
|
|
50
56
|
apipie
|
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: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Pokorny
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-05-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|