bullet_train-api 1.5.0 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/api/open_api_helper.rb +26 -0
- data/lib/bullet_train/api/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: c9311ba2257fbf9075a9c60f6d0d716820a3c13fa92015b00c78f595267c58a3
|
4
|
+
data.tar.gz: fc2a233f8de93e74148ca30c58e91f61e59e35f6f789d19911d8bc60f851eaaa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec5d6a19602fc5297039e5936661fc8fb77d49ff75e461f586dbe84d40abda9ca5af3ad8445d01a40b45a3eab226b210b332ea8c8616f2062d8b9313ee834b80
|
7
|
+
data.tar.gz: f938d50502f7178a00e512d3275e221a359bbc1e8d1ce45409aa7b862f289a9f503fd987a1c70c012461422a193013bd1263fd7127803698b6badce394a48952
|
@@ -68,6 +68,9 @@ module Api
|
|
68
68
|
|
69
69
|
attributes_output = JSON.parse(schema_json)
|
70
70
|
|
71
|
+
# Add "Attributes" part to $ref's
|
72
|
+
update_ref_values!(attributes_output)
|
73
|
+
|
71
74
|
# Rails attachments aren't technically attributes in a model,
|
72
75
|
# so we add the attributes manually to make them available in the API.
|
73
76
|
if model.attachment_reflections.any?
|
@@ -118,5 +121,28 @@ module Api
|
|
118
121
|
methods = controller.action_methods
|
119
122
|
methods.include?("create") || methods.include?("update")
|
120
123
|
end
|
124
|
+
|
125
|
+
def update_ref_values!(hash)
|
126
|
+
hash.each do |key, value|
|
127
|
+
if key == "$ref" && value.is_a?(String) && !value.include?("Attributes")
|
128
|
+
# Extract the part after "#/components/schemas/"
|
129
|
+
schema_part = value.split("#/components/schemas/").last
|
130
|
+
|
131
|
+
# Capitalize each part and join them
|
132
|
+
camelized_schema = schema_part.split("/").map(&:camelize).join
|
133
|
+
|
134
|
+
# Update the value
|
135
|
+
hash[key] = "#/components/schemas/#{camelized_schema}Attributes"
|
136
|
+
elsif value.is_a?(Hash)
|
137
|
+
# Recursively call the method for nested hashes
|
138
|
+
update_ref_values!(value)
|
139
|
+
elsif value.is_a?(Array)
|
140
|
+
# Recursively call the method for each hash in the array
|
141
|
+
value.each do |item|
|
142
|
+
update_ref_values!(item) if item.is_a?(Hash)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
121
147
|
end
|
122
148
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|