oas_rails 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a82d1365d6a90a9901af44fba038995b964bee27d3b55455b064a05250da23da
4
- data.tar.gz: 243af6009f85f7d82a46111a608befab333492ea0e4f24a608f6570e4bfc74eb
3
+ metadata.gz: 2424eec4c6a122256970ba124f71c0f5dfd9b4392875ac678d4868883cc233ae
4
+ data.tar.gz: 182e2434b480920d8cabdd0899c96d48f6c7a69abe5432c33e27f4bc845f3a0c
5
5
  SHA512:
6
- metadata.gz: 85637d8fd3026357294de1f2577784e6e3789fe17852c5295c5cdc6be2940abb9f65c021549a8ba5d40c5cc44d40cfd38045b8a337ff474da63b540b2425fcfe
7
- data.tar.gz: 322d955002a1885b6aa4f5e62a934d71ab2a3600de1f27bc9aa55c164d3d601c2e237be29dc4407c0519c53c7e1a9263262e896598ddbd1bac1051b2ecd88681
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 if route.defaults[:controller].nil?
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
@@ -1,3 +1,3 @@
1
1
  module OasRails
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
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.0
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-30 00:00:00.000000000 Z
11
+ date: 2024-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: esquema