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: 785755b5aed419ca89dc279c2965e5de19cc32bfcbd444a6cb2d25da2704fc8c
4
- data.tar.gz: 774eac0d5dfb757e23b40c2ce90a1eab929615241109824b86696e481b06ab99
3
+ metadata.gz: 85ae0895f424fb76a5e8b50b5f56c82f526a354ec5e9ec562f76219942da99a4
4
+ data.tar.gz: bcfa9af3b8500e7204b4143173f86ef17d7c36083dfd44490047b7f0beac0c44
5
5
  SHA512:
6
- metadata.gz: 58ce0d42fa52b4bbc2c2d5c3bf81e3f23f0e859c62eb2145b63376873ca405f8ee6325b2c447a28b2cd4abd94e74af96986de96fc5ab2c5422b0a8e80a3e83a9
7
- data.tar.gz: 537809a2b7dc85e3d66d1d0c06fd677527e06cc6fb5ba390189cc909dc8c912511677ad5686904e0636254b7d78a79cec85bff7ac4a1ae49a2e7c330a7a87aaf
6
+ metadata.gz: 7b6543957203039aec05ac6c324bd334df075871963f60408d257084df4f908fcac5facff6c69d867d02ad3bef02596a948b784d4f70e12ae7350d6c6dcf6632
7
+ data.tar.gz: 672a557da4a80d153ecc6d37e73ddabecbc1ad03b7556470cca2f038964214fcb061cedec7866cfe1a2b7e87a3ea77496e0f82e14d182c470e24e4ebcd0e0355
@@ -10,7 +10,7 @@
10
10
  </head>
11
11
  <body>
12
12
  <rapi-doc
13
- spec-url = "<%= main_app.oas_rails_path %>.json"
13
+ spec-url = "<%= OasRails::Engine.routes.find_script_name({}) %>.json"
14
14
  theme = "dark"
15
15
  bg-color="#0F172A"
16
16
  text-color= "#f7f7f7"
@@ -52,7 +52,8 @@ module OasRails
52
52
  private
53
53
 
54
54
  def detect_request_body(oas_route)
55
- klass = oas_route.controller.singularize.camelize.constantize
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module OasRails
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.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.4.0
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-10 00:00:00.000000000 Z
11
+ date: 2024-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: esquema