oas_rails 0.4.0 → 0.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85ae0895f424fb76a5e8b50b5f56c82f526a354ec5e9ec562f76219942da99a4
|
4
|
+
data.tar.gz: bcfa9af3b8500e7204b4143173f86ef17d7c36083dfd44490047b7f0beac0c44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b6543957203039aec05ac6c324bd334df075871963f60408d257084df4f908fcac5facff6c69d867d02ad3bef02596a948b784d4f70e12ae7350d6c6dcf6632
|
7
|
+
data.tar.gz: 672a557da4a80d153ecc6d37e73ddabecbc1ad03b7556470cca2f038964214fcb061cedec7866cfe1a2b7e87a3ea77496e0f82e14d182c470e24e4ebcd0e0355
|
@@ -52,7 +52,8 @@ module OasRails
|
|
52
52
|
private
|
53
53
|
|
54
54
|
def detect_request_body(oas_route)
|
55
|
-
klass = oas_route.controller
|
55
|
+
return unless (klass = Utils.find_model_from_route(oas_route.controller))
|
56
|
+
|
56
57
|
from_model_class(klass:, required: true)
|
57
58
|
end
|
58
59
|
end
|
data/lib/oas_rails/utils.rb
CHANGED
@@ -100,6 +100,26 @@ module OasRails
|
|
100
100
|
def class_to_symbol(klass)
|
101
101
|
klass.name.underscore.to_sym
|
102
102
|
end
|
103
|
+
|
104
|
+
def find_model_from_route(path)
|
105
|
+
parts = path.split('/')
|
106
|
+
model_name = parts.last.singularize.camelize
|
107
|
+
|
108
|
+
namespace_combinations = (0..parts.size).map do |i|
|
109
|
+
parts.first(i).map(&:camelize).join('::')
|
110
|
+
end
|
111
|
+
|
112
|
+
namespace_combinations.reverse.each do |namespace|
|
113
|
+
full_class_name = [namespace, model_name].reject(&:empty?).join('::')
|
114
|
+
begin
|
115
|
+
return full_class_name.constantize
|
116
|
+
rescue NameError
|
117
|
+
next
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
nil # Return nil if no matching constant is found
|
122
|
+
end
|
103
123
|
end
|
104
124
|
end
|
105
125
|
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.4.
|
4
|
+
version: 0.4.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-08-
|
11
|
+
date: 2024-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: esquema
|