oas_rails 0.2.0 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/oas_rails/route_extractor.rb +24 -1
- data/lib/oas_rails/version.rb +1 -1
- 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: 2424eec4c6a122256970ba124f71c0f5dfd9b4392875ac678d4868883cc233ae
|
4
|
+
data.tar.gz: 182e2434b480920d8cabdd0899c96d48f6c7a69abe5432c33e27f4bc845f3a0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0437d44b6b053a3e95659ed43957d3455826ba2981f02140c23f323c5997434aa3c1adbe232188da55b6f62e3ff67e3c83a4a58d64973023555448f14ae964f
|
7
|
+
data.tar.gz: 5f2edc1bc10dab27b4ff13c9a583bf73c3855dd65c06055dfd26b63d89034d607d5794cf331356b8759443b1a0e072cc0a96fbbc6260ea83641826c0ca66f96c
|
@@ -76,13 +76,36 @@ module OasRails
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def valid_api_route?(route)
|
79
|
-
return false
|
79
|
+
return false unless valid_route_implementation?(route)
|
80
80
|
return false if RAILS_DEFAULT_CONTROLLERS.any? { |default| route.defaults[:controller].start_with?(default) }
|
81
81
|
return false if RAILS_DEFAULT_PATHS.any? { |path| route.path.spec.to_s.include?(path) }
|
82
82
|
return false unless route.path.spec.to_s.start_with?(OasRails.config.api_path)
|
83
83
|
|
84
84
|
true
|
85
85
|
end
|
86
|
+
|
87
|
+
# Checks if a route has a valid implementation.
|
88
|
+
#
|
89
|
+
# This method verifies that both the controller and the action specified
|
90
|
+
# in the route exist. It checks if the controller class is defined and
|
91
|
+
# if the action method is implemented within that controller.
|
92
|
+
#
|
93
|
+
# @param route [ActionDispatch::Journey::Route] The route to check.
|
94
|
+
# @return [Boolean] true if both the controller and action exist, false otherwise.
|
95
|
+
def valid_route_implementation?(route)
|
96
|
+
controller_name = route.defaults[:controller]&.camelize
|
97
|
+
action_name = route.defaults[:action]
|
98
|
+
|
99
|
+
return false if controller_name.blank? || action_name.blank?
|
100
|
+
|
101
|
+
controller_class = "#{controller_name}Controller".safe_constantize
|
102
|
+
|
103
|
+
if controller_class.nil?
|
104
|
+
false
|
105
|
+
else
|
106
|
+
controller_class.instance_methods.include?(action_name.to_sym)
|
107
|
+
end
|
108
|
+
end
|
86
109
|
end
|
87
110
|
end
|
88
111
|
end
|
data/lib/oas_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oas_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a-chacon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: esquema
|