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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de12a8ab6012fe5702251d070eb6e67cc87b07e192a10bb3f1c5d17ff3de800f
4
- data.tar.gz: e17e7f7cbe86523ada3bafad13e84d4042d698f2e47af6d9611b9d2bb8c769a9
3
+ metadata.gz: aacf0a8db6373136ed38f4f56d422e2c4d0e7ed5e38c8d7ea791372641d48ff0
4
+ data.tar.gz: 9b45c0f4482a70cb1ab6c0a46d8b7b9b48d2d704ff987deb403905e63ff44f82
5
5
  SHA512:
6
- metadata.gz: b900c0af11788aa07ed01e2374af8615f3411069204947a1f967756456f40b6eabb58379befc78bfdcab389919f6f84a11642f70b46802f23aeca12259314ac0
7
- data.tar.gz: 1d836923c101d1a0077e79d3c1a7267135d8ec1899154dbec4d2f547f39ca010de56b2fe53db5f5d8a20a479a39091a15a5410fd9970b431c24c8d2ccf751947
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
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Api
3
- VERSION = "1.5.1"
3
+ VERSION = "1.6.0"
4
4
  end
5
5
  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.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-02 00:00:00.000000000 Z
11
+ date: 2023-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard