bullet_train-api 1.6.26 → 1.6.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3da820ecd4427cce764eab98c2b258a9677022ea138e990020176c1c16a5879f
|
4
|
+
data.tar.gz: 52fd62ced5483d47f5d4e31978a2788cfea8a46917e5d945eeffb0ebe203c18c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb260cba10aaf616fa8b4ba8b7d3ab4f358dc384af7c860ff2d53389de318bfc46f9acdedde06d4cb8d4759b92b9dcff815d2c0f63bc8619e8020a062fa22c2f
|
7
|
+
data.tar.gz: c69f7552837e1706946a698ab6aa8ca470aa0b7f2a549d4ff2fe44e740ec58fa851e622979e684b080bb4f42517d75dc4972d9944e20354824e1737a10d337bc
|
@@ -38,8 +38,8 @@ module Api
|
|
38
38
|
end
|
39
39
|
|
40
40
|
if custom_output
|
41
|
-
merge = deep_merge(YAML.
|
42
|
-
# YAML.
|
41
|
+
merge = deep_merge(YAML.safe_load(output), YAML.safe_load(custom_output)).to_yaml.html_safe
|
42
|
+
# YAML.safe_load escapes emojis https://github.com/ruby/psych/issues/371
|
43
43
|
# Next line returns emojis back and removes yaml garbage
|
44
44
|
output = merge.gsub("---", "").gsub(/\\u[\da-f]{8}/i) { |m| [m[-8..].to_i(16)].pack("U") }
|
45
45
|
end
|
@@ -47,7 +47,9 @@ module Api
|
|
47
47
|
indent(output, 1)
|
48
48
|
end
|
49
49
|
|
50
|
-
def automatic_components_for(model,
|
50
|
+
def automatic_components_for(model, **options)
|
51
|
+
locals = options.delete(:locals) || {}
|
52
|
+
|
51
53
|
path = "app/views/api/#{@version}"
|
52
54
|
paths = [path, "app/views"] + gem_paths.product(%W[/#{path} /app/views]).map(&:join)
|
53
55
|
|
@@ -76,6 +78,9 @@ module Api
|
|
76
78
|
|
77
79
|
attributes_output = JSON.parse(schema_json)
|
78
80
|
|
81
|
+
# Allow customization of Attributes
|
82
|
+
customize_component!(attributes_output, options[:attributes]) if options[:attributes]
|
83
|
+
|
79
84
|
# Add "Attributes" part to $ref's
|
80
85
|
update_ref_values!(attributes_output)
|
81
86
|
|
@@ -106,6 +111,9 @@ module Api
|
|
106
111
|
parameters_output["properties"].select! { |key| strong_parameter_keys.include?(key.to_sym) }
|
107
112
|
parameters_output["example"]&.select! { |key, value| strong_parameter_keys.include?(key.to_sym) && value.present? }
|
108
113
|
|
114
|
+
# Allow customization of Parameters
|
115
|
+
customize_component!(parameters_output, options[:parameters]) if options[:parameters]
|
116
|
+
|
109
117
|
(
|
110
118
|
indent(attributes_output.to_yaml.gsub("---", "#{model.name.gsub("::", "")}Attributes:"), 3) +
|
111
119
|
indent(" " + parameters_output.to_yaml.gsub("---", "#{model.name.gsub("::", "")}Parameters:"), 3)
|
@@ -164,5 +172,41 @@ module Api
|
|
164
172
|
end
|
165
173
|
end
|
166
174
|
end
|
175
|
+
|
176
|
+
def customize_component!(original, custom)
|
177
|
+
custom = custom.deep_stringify_keys.deep_transform_values { |v| v.is_a?(Symbol) ? v.to_s : v }
|
178
|
+
|
179
|
+
if custom.key?("add")
|
180
|
+
custom["add"].each do |property, details|
|
181
|
+
if details["required"]
|
182
|
+
original["required"] << property
|
183
|
+
details.delete("required")
|
184
|
+
end
|
185
|
+
original["properties"][property] = details
|
186
|
+
if details["example"]
|
187
|
+
original["example"][property] = details["example"]
|
188
|
+
details.delete("example")
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
if custom.key?("remove")
|
194
|
+
Array(custom["remove"]).each do |property|
|
195
|
+
original["required"].delete(property)
|
196
|
+
original["properties"].delete(property)
|
197
|
+
original["example"].delete(property)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
if custom.key?("only")
|
202
|
+
original["properties"].keys.each do |property|
|
203
|
+
unless Array(custom["only"]).include?(property)
|
204
|
+
original["properties"].delete(property)
|
205
|
+
original["required"].delete(property)
|
206
|
+
original["example"].delete(property)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
167
211
|
end
|
168
212
|
end
|
@@ -20,38 +20,56 @@ en:
|
|
20
20
|
destroy: Are you sure you want to remove %{access_token_name}? This will break any active integrations using this token and can't be undone.
|
21
21
|
fields: &fields
|
22
22
|
id:
|
23
|
-
heading: Access Token ID
|
23
|
+
heading: &id Access Token ID
|
24
|
+
api_title: *id
|
25
|
+
api_description: *id
|
24
26
|
application_id:
|
25
|
-
heading: Application ID
|
27
|
+
heading: &application_id Application ID
|
28
|
+
api_title: *application_id
|
29
|
+
api_description: *application_id
|
26
30
|
token:
|
27
31
|
_: &token Token
|
28
32
|
label: *token
|
29
33
|
heading: *token
|
34
|
+
api_title: *token
|
35
|
+
api_description: *token
|
30
36
|
expires_in:
|
31
37
|
_: &expires_in Expires In
|
32
38
|
label: *expires_in
|
33
39
|
heading: *expires_in
|
40
|
+
api_title: *expires_in
|
41
|
+
api_description: *expires_in
|
34
42
|
scopes:
|
35
43
|
_: &scopes Scopes
|
36
44
|
label: *scopes
|
37
45
|
heading: *scopes
|
46
|
+
api_title: *scopes
|
47
|
+
api_description: *scopes
|
38
48
|
last_used_at:
|
39
49
|
_: &last_used_at Last Used At
|
40
50
|
label: *last_used_at
|
41
51
|
heading: *last_used_at
|
52
|
+
api_title: *last_used_at
|
53
|
+
api_description: *last_used_at
|
42
54
|
description:
|
43
55
|
_: &description Description
|
44
56
|
label: *description
|
45
57
|
heading: *description
|
58
|
+
api_title: *description
|
59
|
+
api_description: *description
|
46
60
|
# 🚅 super scaffolding will insert new fields above this line.
|
47
61
|
created_at:
|
48
62
|
_: &created_at Created
|
49
63
|
label: *created_at
|
50
64
|
heading: *created_at
|
65
|
+
api_title: *created_at
|
66
|
+
api_description: *created_at
|
51
67
|
updated_at:
|
52
68
|
_: &updated_at Updated
|
53
69
|
label: *updated_at
|
54
70
|
heading: *updated_at
|
71
|
+
api_title: *updated_at
|
72
|
+
api_description: *updated_at
|
55
73
|
api:
|
56
74
|
collection_actions: "Collection Actions for Access Tokens"
|
57
75
|
index: "List Access Tokens"
|
@@ -24,32 +24,46 @@ en:
|
|
24
24
|
name:
|
25
25
|
_: &name Name
|
26
26
|
label: *name
|
27
|
-
heading: Application Name
|
27
|
+
heading: &application_name Application Name
|
28
|
+
api_title: *application_name
|
29
|
+
api_description: *application_name
|
28
30
|
|
29
31
|
redirect_uri:
|
30
32
|
_: &redirect_uri Redirect URI
|
31
33
|
label: *redirect_uri
|
32
34
|
heading: *redirect_uri
|
35
|
+
api_title: *redirect_uri
|
36
|
+
api_description: *redirect_uri
|
33
37
|
help: This is only required if you're building an OAuth2-powered integration for other users.
|
34
38
|
|
35
39
|
uid:
|
36
|
-
heading: Client UID
|
40
|
+
heading: &uid Client UID
|
41
|
+
api_title: *uid
|
42
|
+
api_description: *uid
|
37
43
|
|
38
44
|
secret:
|
39
|
-
heading: Client Secret
|
45
|
+
heading: &secret Client Secret
|
46
|
+
api_title: *secret
|
47
|
+
api_description: *secret
|
40
48
|
|
41
49
|
label_string:
|
42
|
-
heading:
|
50
|
+
heading: *application_name
|
51
|
+
api_title: *application_name
|
52
|
+
api_description: *application_name
|
43
53
|
|
44
54
|
# 🚅 super scaffolding will insert new fields above this line.
|
45
55
|
created_at:
|
46
56
|
_: &created_at Added
|
47
57
|
label: *created_at
|
48
58
|
heading: *created_at
|
59
|
+
api_title: *created_at
|
60
|
+
api_description: *created_at
|
49
61
|
updated_at:
|
50
62
|
_: &updated_at Updated
|
51
63
|
label: *updated_at
|
52
64
|
heading: *updated_at
|
65
|
+
api_title: *updated_at
|
66
|
+
api_description: *updated_at
|
53
67
|
index:
|
54
68
|
section: "%{teams_possessive} Platform Applications"
|
55
69
|
contexts:
|
@@ -146,5 +146,103 @@ namespace :bullet_train do
|
|
146
146
|
)
|
147
147
|
end
|
148
148
|
end
|
149
|
+
|
150
|
+
desc "Create `api_title` and `api_description` translations"
|
151
|
+
task create_translations: :environment do
|
152
|
+
# Define the root of the locales directory
|
153
|
+
locales_root = Rails.root.join("config", "locales").to_s
|
154
|
+
|
155
|
+
# Define the backup directory
|
156
|
+
backup_dir = Rails.root.join("tmp", "locales_backup")
|
157
|
+
FileUtils.mkdir_p(backup_dir) unless Dir.exist?(backup_dir)
|
158
|
+
|
159
|
+
original_files = Dir.glob("#{locales_root}/**/*.yml")
|
160
|
+
differing_files_count = 0
|
161
|
+
|
162
|
+
original_files.each do |file|
|
163
|
+
puts "Processing #{file}..."
|
164
|
+
|
165
|
+
lines = File.readlines(file)
|
166
|
+
new_content = []
|
167
|
+
inside_fields = false
|
168
|
+
current_field = nil
|
169
|
+
fields_indentation = 4
|
170
|
+
api_title_exists = false
|
171
|
+
api_description_exists = false
|
172
|
+
|
173
|
+
# Read the entire file as a string
|
174
|
+
lines.each_with_index do |line, index|
|
175
|
+
# fields are always under locale:model:
|
176
|
+
if line.start_with?("#{" " * fields_indentation}fields:")
|
177
|
+
inside_fields = true
|
178
|
+
new_content << line
|
179
|
+
next
|
180
|
+
end
|
181
|
+
|
182
|
+
if inside_fields
|
183
|
+
current_indentation = line.index(/\S/) || 0
|
184
|
+
if current_indentation <= fields_indentation
|
185
|
+
# We've exited the fields block
|
186
|
+
inside_fields = false
|
187
|
+
current_field = nil
|
188
|
+
elsif current_indentation == fields_indentation + 2
|
189
|
+
# We're on a line with a field name
|
190
|
+
current_field = line.strip.split(":").first
|
191
|
+
|
192
|
+
api_title_exists = false
|
193
|
+
api_description_exists = false
|
194
|
+
|
195
|
+
n = 1
|
196
|
+
until index + n >= lines.length || (lines[index + n].index(/\S/) || 0) <= fields_indentation
|
197
|
+
if lines[index + n].strip.start_with?("api_title:")
|
198
|
+
api_title_exists = true
|
199
|
+
elsif lines[index + n].strip.start_with?("api_description:")
|
200
|
+
api_description_exists = true
|
201
|
+
end
|
202
|
+
n += 1
|
203
|
+
end
|
204
|
+
|
205
|
+
elsif current_field && line.strip.start_with?("heading:")
|
206
|
+
heading_value = line.split(":").last&.strip
|
207
|
+
indent = " " * current_indentation
|
208
|
+
|
209
|
+
if heading_value&.start_with?("&", "*")
|
210
|
+
new_content << line
|
211
|
+
else
|
212
|
+
heading_value = "&#{current_field} #{heading_value}"
|
213
|
+
new_content << "#{indent}heading: #{heading_value}\n"
|
214
|
+
end
|
215
|
+
|
216
|
+
field_key = heading_value[1..]&.split(" ")&.first
|
217
|
+
new_content << "#{indent}api_title: *#{field_key}\n" unless api_title_exists
|
218
|
+
new_content << "#{indent}api_description: *#{field_key}\n" unless api_description_exists
|
219
|
+
|
220
|
+
next
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
new_content << line
|
225
|
+
end
|
226
|
+
|
227
|
+
# Only write to file if there are changes
|
228
|
+
unless lines.join == new_content.join
|
229
|
+
differing_files_count += 1
|
230
|
+
|
231
|
+
# Compute the relative path manually
|
232
|
+
relative_path = file.sub(/^#{Regexp.escape(locales_root)}\/?/, "")
|
233
|
+
|
234
|
+
backup_path = File.join(backup_dir, relative_path)
|
235
|
+
FileUtils.mkdir_p(File.dirname(backup_path))
|
236
|
+
FileUtils.cp(file, backup_path)
|
237
|
+
puts "↳ Updating, backup created: #{backup_path}"
|
238
|
+
|
239
|
+
# Write the updated data back to the file
|
240
|
+
File.write(file, new_content.join)
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
puts "---"
|
245
|
+
puts "Total files updated: #{differing_files_count}/#{original_files.size}"
|
246
|
+
end
|
149
247
|
end
|
150
248
|
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.6.
|
4
|
+
version: 1.6.28
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -246,7 +246,9 @@ licenses:
|
|
246
246
|
metadata:
|
247
247
|
homepage_uri: https://github.com/bullet-train-co/bullet_train-core/tree/main/bullet_train-api
|
248
248
|
source_code_uri: https://github.com/bullet-train-co/bullet_train-core/tree/main/bullet_train-api
|
249
|
-
post_install_message:
|
249
|
+
post_install_message: "\n Bullet Train is switching to separate translations for
|
250
|
+
API documentation.\n To automatically update existing translations, run once:\n\n
|
251
|
+
\ bundle exec rake bullet_train:api:create_translations\n\n "
|
250
252
|
rdoc_options: []
|
251
253
|
require_paths:
|
252
254
|
- lib
|
@@ -261,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
261
263
|
- !ruby/object:Gem::Version
|
262
264
|
version: '0'
|
263
265
|
requirements: []
|
264
|
-
rubygems_version: 3.
|
266
|
+
rubygems_version: 3.5.3
|
265
267
|
signing_key:
|
266
268
|
specification_version: 4
|
267
269
|
summary: Bullet Train API
|