bullet_train-api 1.3.13 → 1.3.14
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 +4 -4
- data/app/helpers/api/open_api_helper.rb +3 -2
- data/app/views/api/v1/open_api/shared/_paths.yaml.erb +2 -2
- data/lib/bullet_train/api/example_bot.rb +15 -3
- data/lib/bullet_train/api/version.rb +1 -1
- data/lib/bullet_train/api.rb +1 -0
- data/lib/jbuilder/values_transformer.rb +13 -0
- data/lib/tasks/bullet_train/api_tasks.rake +16 -0
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1afcea46978b7420ab6561c17b1d55c03cc01a85be1ca29b3bd384e371a10e5c
|
|
4
|
+
data.tar.gz: 26f2e5abb15ef1359f5a846232ba0c953aa31a60100466a5c4594d27eb9d0e44
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2728e7625569f7a11eea0b36840d9bbc5b95a727f5fc369d7a575b092a2ece1048fd93993a798868b94a755ceec55f12504fc8eee2bb3bb24be0acad1d2c752d
|
|
7
|
+
data.tar.gz: cb185815afbab983770c746ccddd676956d1d8f502f795504a54d20e48c1d810a0073e1208648488d2bade4807e9323a6c1e9e37dbb38da2c1d806f0d35dc156
|
|
@@ -60,7 +60,7 @@ module Api
|
|
|
60
60
|
}.merge(locals))
|
|
61
61
|
|
|
62
62
|
schema_json = jbuilder.json(
|
|
63
|
-
model.new,
|
|
63
|
+
FactoryBot.example(model.model_name.param_key.to_sym) || model.new,
|
|
64
64
|
title: I18n.t("#{model.name.underscore.pluralize}.label"),
|
|
65
65
|
# TODO Improve this. We don't have a generic description for models we can use here.
|
|
66
66
|
description: I18n.t("#{model.name.underscore.pluralize}.label"),
|
|
@@ -92,7 +92,8 @@ module Api
|
|
|
92
92
|
|
|
93
93
|
parameters_output = JSON.parse(schema_json)
|
|
94
94
|
parameters_output["required"].select! { |key| strong_parameter_keys.include?(key.to_sym) }
|
|
95
|
-
parameters_output["properties"].select! { |key
|
|
95
|
+
parameters_output["properties"].select! { |key| strong_parameter_keys.include?(key.to_sym) }
|
|
96
|
+
parameters_output["example"]&.select! { |key, value| strong_parameter_keys.include?(key.to_sym) && value.present? }
|
|
96
97
|
|
|
97
98
|
(
|
|
98
99
|
indent(attributes_output.to_yaml.gsub("---", "#{model.name.gsub("::", "")}Attributes:"), 3) +
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
in: path
|
|
13
13
|
required: true
|
|
14
14
|
schema:
|
|
15
|
-
type:
|
|
15
|
+
type: integer
|
|
16
16
|
- $ref: "#/components/parameters/after"
|
|
17
17
|
responses:
|
|
18
18
|
"404":
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
in: path
|
|
45
45
|
required: true
|
|
46
46
|
schema:
|
|
47
|
-
type:
|
|
47
|
+
type: integer
|
|
48
48
|
requestBody:
|
|
49
49
|
description: "Information about a new Tangible Thing"
|
|
50
50
|
required: true
|
|
@@ -71,8 +71,17 @@ module FactoryBot
|
|
|
71
71
|
clone.send("#{name}=", associations)
|
|
72
72
|
@tables_to_reset << name
|
|
73
73
|
elsif %i[belongs_to has_one].include?(reflection.macro)
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
# Calling e.g. address.team= throws an error,
|
|
75
|
+
# if address has_one team through person
|
|
76
|
+
# and person has_one team through company
|
|
77
|
+
# and company belongs_to team
|
|
78
|
+
# so the resulting error will be caught here and a warning logged.
|
|
79
|
+
begin
|
|
80
|
+
clone.send("#{name}=", instance.send(name).clone)
|
|
81
|
+
@tables_to_reset << name.pluralize
|
|
82
|
+
rescue ActiveRecord::HasOneThroughNestedAssociationsAreReadonly
|
|
83
|
+
Rails.logger.warn("ExampleBot.deep_clone ignored setting #{name} of #{instance}")
|
|
84
|
+
end
|
|
76
85
|
end
|
|
77
86
|
end
|
|
78
87
|
|
|
@@ -90,7 +99,7 @@ module FactoryBot
|
|
|
90
99
|
else
|
|
91
100
|
template, class_name, var_name, values = _set_values("get_example", model)
|
|
92
101
|
|
|
93
|
-
|
|
102
|
+
if method.end_with?("parameters")
|
|
94
103
|
if has_strong_parameters?("::Api::#{version.upcase}::#{class_name.pluralize}Controller".constantize)
|
|
95
104
|
strong_params_module = "::Api::#{version.upcase}::#{class_name.pluralize}Controller::StrongParameters".constantize
|
|
96
105
|
strong_parameter_keys = BulletTrain::Api::StrongParametersReporter.new(class_name.constantize, strong_params_module).report
|
|
@@ -103,6 +112,9 @@ module FactoryBot
|
|
|
103
112
|
parameters_output = JSON.parse(output)
|
|
104
113
|
parameters_output&.select! { |key| strong_parameter_keys.include?(key.to_sym) }
|
|
105
114
|
|
|
115
|
+
# Wrapping the example as parameters should be wrapped with the model name:
|
|
116
|
+
parameters_output = {model.to_s => parameters_output}
|
|
117
|
+
|
|
106
118
|
return indent(parameters_output.to_yaml.delete_prefix("---\n"), 6).html_safe
|
|
107
119
|
end
|
|
108
120
|
return nil
|
data/lib/bullet_train/api.rb
CHANGED
|
@@ -128,5 +128,21 @@ namespace :bullet_train do
|
|
|
128
128
|
puts "Failed to download the OpenAPI Document. Status code: #{response.status}"
|
|
129
129
|
end
|
|
130
130
|
end
|
|
131
|
+
|
|
132
|
+
desc "Export the OpenAPI schema for the application"
|
|
133
|
+
task export_openapi_schema: :environment do
|
|
134
|
+
@version = BulletTrain::Api.current_version
|
|
135
|
+
File.open("openapi-#{Time.now.strftime("%Y%m%d-%H%M%S")}.yaml", "w+") do |f|
|
|
136
|
+
f.binmode
|
|
137
|
+
f.write(
|
|
138
|
+
ApplicationController.renderer.render(
|
|
139
|
+
template: "api/#{@version}/open_api/index",
|
|
140
|
+
layout: false,
|
|
141
|
+
format: :text,
|
|
142
|
+
assigns: {version: @version}
|
|
143
|
+
)
|
|
144
|
+
)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
131
147
|
end
|
|
132
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.3.
|
|
4
|
+
version: 1.3.14
|
|
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-08-
|
|
11
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: standard
|
|
@@ -100,14 +100,14 @@ dependencies:
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - ">="
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: 2.
|
|
103
|
+
version: 2.2.0
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - ">="
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: 2.
|
|
110
|
+
version: 2.2.0
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: factory_bot
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -212,6 +212,7 @@ files:
|
|
|
212
212
|
- lib/bullet_train/api/version.rb
|
|
213
213
|
- lib/bullet_train/platform.rb
|
|
214
214
|
- lib/bullet_train/platform/connection_workflow.rb
|
|
215
|
+
- lib/jbuilder/values_transformer.rb
|
|
215
216
|
- lib/tasks/bullet_train/api_tasks.rake
|
|
216
217
|
- lib/tokens_controller.rb
|
|
217
218
|
homepage: https://github.com/bullet-train-co/bullet_train-core/tree/main/bullet_train-api
|