bullet_train-api 1.5.1 → 1.6.0
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: aacf0a8db6373136ed38f4f56d422e2c4d0e7ed5e38c8d7ea791372641d48ff0
|
4
|
+
data.tar.gz: 9b45c0f4482a70cb1ab6c0a46d8b7b9b48d2d704ff987deb403905e63ff44f82
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ebfb9152093fe68e627735ad610235d5e50f760b529000f99baf913c022d317581c69b0c23644ceafec514cd702dea14fae7bbe1b625f3a2cce6bf5ef05cc6f
|
7
|
+
data.tar.gz: 87ac5c5a94feeeacc429792cf91d68518b429604748757bddea08ca9977f1e23101ab00bf37029d36d453b2092fafda93103dad3a55ae17255da382dda620750
|
@@ -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.
|
4
|
+
version: 1.6.0
|
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-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|