bullet_train-api 1.5.1 → 1.5.2

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: c9311ba2257fbf9075a9c60f6d0d716820a3c13fa92015b00c78f595267c58a3
4
+ data.tar.gz: fc2a233f8de93e74148ca30c58e91f61e59e35f6f789d19911d8bc60f851eaaa
5
5
  SHA512:
6
- metadata.gz: b900c0af11788aa07ed01e2374af8615f3411069204947a1f967756456f40b6eabb58379befc78bfdcab389919f6f84a11642f70b46802f23aeca12259314ac0
7
- data.tar.gz: 1d836923c101d1a0077e79d3c1a7267135d8ec1899154dbec4d2f547f39ca010de56b2fe53db5f5d8a20a479a39091a15a5410fd9970b431c24c8d2ccf751947
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
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Api
3
- VERSION = "1.5.1"
3
+ VERSION = "1.5.2"
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.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-02 00:00:00.000000000 Z
11
+ date: 2023-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard