bullet_train-api 1.2.23 → 1.2.24

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: 52964332e89aebd4034e1a1d6da5f4e96065920023b79a002360787140845d2c
4
- data.tar.gz: 969c41617e73866c1fca4658846bc95a425dfb86e608f9f1687dc295a24248b6
3
+ metadata.gz: 87ee8b24dbab751228f331fe26950afa6fe93f3525092767831bd9659ed5d6f5
4
+ data.tar.gz: 1f5f064679487f87b01e5d5940efc121b72f5dbe86586b8bd07e63b83406b3f9
5
5
  SHA512:
6
- metadata.gz: 39313d6d4963ec35c2b606d5bd967b1f04668dfc47de6269271b80450b9e5c5de872f93fa0b4bc8f194fe3ebc25a5507b523d2bf512a09401c8f1bb62b131c95
7
- data.tar.gz: 19b9778baedbea755ab32b48b192b7141408a9b4467447a49631d9b5ab550651da37cb31628c4792882c44e059e790db4d42e621d0f4fcb61b8e9b7e38de56ee
6
+ metadata.gz: 897ae05b0fd124b0418ee6e242e570d7f20b76aafdc29b1ebcae3a44b76621f095f319ad00a7306edcf01f99b87b9b830289f38834dd3e7ab5aee92276629477
7
+ data.tar.gz: a5a7f22e19bb8137c60b814343a79a11905cc9e26c76f45691e5d9edb07d1cd13b18f2cd540f6d41f114d21c4c7f2761680f624bc39a378009d9a8772e0f180e
@@ -33,6 +33,30 @@ module Api
33
33
  def automatic_paths_for(model, parent, except: [])
34
34
  output = render("api/#{@version}/open_api/shared/paths", except: except)
35
35
  output = Scaffolding::Transformer.new(model.name, [parent&.name]).transform_string(output).html_safe
36
+
37
+ # There are some placeholders specific to this method that we still need to transform.
38
+ model_symbol = model.name.underscore.tr("/", "_")
39
+
40
+ if (get_example = FactoryBot.get_example(model_symbol, version: @version))
41
+ output.gsub!("🚅 get_example", get_example)
42
+ end
43
+
44
+ if (post_parameters = FactoryBot.post_parameters(model_symbol, version: @version))
45
+ output.gsub!("🚅 post_parameters", post_parameters)
46
+ end
47
+
48
+ if (post_examples = FactoryBot.post_examples(model_symbol, version: @version))
49
+ output.gsub!("🚅 post_examples", post_examples)
50
+ end
51
+
52
+ if (put_parameters = FactoryBot.put_parameters(model_symbol, version: @version))
53
+ output.gsub!("🚅 put_parameters", put_parameters)
54
+ end
55
+
56
+ if (put_example = FactoryBot.put_example(model_symbol, version: @version))
57
+ output.gsub!("🚅 put_example", put_example)
58
+ end
59
+
36
60
  indent(output, 1)
37
61
  end
38
62
 
@@ -31,7 +31,7 @@
31
31
  items:
32
32
  $ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingAttributes"
33
33
  example:
34
- <%= FactoryBot.get_example(:scaffolding_completely_concrete_tangible_thing, version: @version) %>
34
+ 🚅 get_example
35
35
  <% end %>
36
36
  <% unless except.include?(:create) %>
37
37
  post:
@@ -57,7 +57,7 @@
57
57
  type: object
58
58
  $ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingParameters"
59
59
  example:
60
- <%= FactoryBot.post_parameters(:scaffolding_completely_concrete_tangible_thing, version: @version) %>
60
+ 🚅 post_parameters
61
61
  responses:
62
62
  "404":
63
63
  description: "Not Found"
@@ -68,7 +68,7 @@
68
68
  schema:
69
69
  $ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingAttributes"
70
70
  example:
71
- <%= FactoryBot.post_examples(:scaffolding_completely_concrete_tangible_thing, version: @version) %>
71
+ 🚅 post_examples
72
72
  <% end %>
73
73
  <% end %>
74
74
  <% unless except.include?(:show) && except.include?(:update) && except.include?(:destroy) %>
@@ -91,7 +91,7 @@
91
91
  schema:
92
92
  $ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingAttributes"
93
93
  example:
94
- <%= FactoryBot.get_example(:scaffolding_completely_concrete_tangible_thing, version: @version) %>
94
+ 🚅 get_example
95
95
  <% end %>
96
96
  <% unless except.include?(:update) %>
97
97
  put:
@@ -113,7 +113,7 @@
113
113
  type: object
114
114
  $ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingParameters"
115
115
  example:
116
- <%= FactoryBot.put_parameters(:scaffolding_completely_concrete_tangible_thing, version: @version) %>
116
+ 🚅 put_parameters
117
117
  responses:
118
118
  "404":
119
119
  description: "Not Found"
@@ -124,7 +124,7 @@
124
124
  schema:
125
125
  $ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingAttributes"
126
126
  example:
127
- <%= FactoryBot.put_example(:scaffolding_completely_concrete_tangible_thing, version: @version) %>
127
+ 🚅 put_example
128
128
  <% end %>
129
129
  <% unless except.include?(:destroy) %>
130
130
  delete:
@@ -48,8 +48,13 @@ module FactoryBot
48
48
  private
49
49
 
50
50
  def factory(model)
51
+ # TODO Why do we sometimes get a real object here and sometimes just a model name as a symbol?
52
+ unless model.is_a?(String)
53
+ model = model.name.underscore.tr("/", "_").to_sym
54
+ end
55
+
51
56
  factories = FactoryBot.factories.instance_variable_get(:@items).keys
52
- factories.include?("#{model}_example") ? "#{model}_example" : model
57
+ factories.include?("#{model}_example") ? "#{model}_example".to_sym : model
53
58
  end
54
59
 
55
60
  def reset_tables!
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Api
3
- VERSION = "1.2.23"
3
+ VERSION = "1.2.24"
4
4
  end
5
5
  end
@@ -1,6 +1,9 @@
1
1
  require "scaffolding"
2
2
  require "scaffolding/file_manipulator"
3
3
 
4
+ require "faraday"
5
+ require "tempfile"
6
+
4
7
  namespace :bullet_train do
5
8
  namespace :api do
6
9
  desc "Bump the current version of application's API"
@@ -88,5 +91,42 @@ namespace :bullet_train do
88
91
 
89
92
  puts "Finished bumping to #{new_version}"
90
93
  end
94
+
95
+ desc "Bump the current version of application's API"
96
+ task push_to_redocly: :environment do
97
+ include Rails.application.routes.url_helpers
98
+
99
+ raise "You need to set REDOCLY_ORGANIZATION_ID in your environment. You can fetch it from the URL when you're on your Redocly dashboard." unless ENV["REDOCLY_ORGANIZATION_ID"].present?
100
+ raise "You need to set REDOCLY_API_KEY in your environment. You can create one at https://app.redocly.com/org/#{ENV["REDOCLY_ORGANIZATION_ID"]}/settings/api-keys ." unless ENV["REDOCLY_API_KEY"].present?
101
+
102
+ # Create a new Faraday connection
103
+ conn = Faraday.new(api_url(version: BulletTrain::Api.current_version))
104
+
105
+ # Fetch the file
106
+ response = conn.get
107
+
108
+ # Check if the request was successful
109
+ if response.status == 200
110
+ # Create a temp file
111
+ temp_file = Tempfile.new(["openapi-", ".yaml"])
112
+
113
+ # Write the file content to the temp file
114
+ temp_file.binmode
115
+ temp_file.write(response.body)
116
+ temp_file.rewind
117
+
118
+ # Close and delete the temp file when the script exits
119
+ temp_file.close
120
+ puts "File downloaded and saved to: #{temp_file.path}"
121
+
122
+ puts `echo "#{ENV["REDOCLY_API_KEY"]}" | redocly login`
123
+
124
+ puts `redocly push #{temp_file.path} "@#{ENV["REDOCLY_ORGANIZATION_ID"]}/#{I18n.t("application.name")}@#{BulletTrain::Api.current_version}" --public --upsert`
125
+
126
+ temp_file.unlink
127
+ else
128
+ puts "Failed to download the OpenAPI Document. Status code: #{response.status}"
129
+ end
130
+ end
91
131
  end
92
132
  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.2.23
4
+ version: 1.2.24
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-04-01 00:00:00.000000000 Z
11
+ date: 2023-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard
@@ -231,7 +231,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
231
  - !ruby/object:Gem::Version
232
232
  version: '0'
233
233
  requirements: []
234
- rubygems_version: 3.3.7
234
+ rubygems_version: 3.4.6
235
235
  signing_key:
236
236
  specification_version: 4
237
237
  summary: Bullet Train API