bullet_train-api 1.0.12 → 1.0.13

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: 27ca15eddb9b29b85afaba362068e42a8c7d844226d1aa5b37c37b11ba3f356f
4
- data.tar.gz: 6e5ae250fddaa6b461e867e006abf9d30fe9fcde8f846eaf120a12130396edcf
3
+ metadata.gz: 766d45178150439d1076f0330084c75f25f6349943a6cd90ae55061a9900cd08
4
+ data.tar.gz: 578914d5271157d1a3709174464e7fcd15441c6391a3fcc5ee9c9dd997decb06
5
5
  SHA512:
6
- metadata.gz: 1326b4449fb8f96c87377cd5cc5cd35921234e9b7ed28926bd7dd49ca4ea73db401d59fd95c2e847f1c709bbfb606a1a0a01e3f46fd8bb6d983e51d3c6b03237
7
- data.tar.gz: 530412b77a184ca0c271e50b2678f4427513f53d3dc2ab45457661586fa7f55846ac1cf0db62391a321aadeef1c393d1b4e48eead90b7aff5211398f29597f7f
6
+ metadata.gz: 9f56d8880d393c5d9eb568b345328cca556fb5d6592187833395959fbf8b2cfd8a78cb9f9cf6a53b695b1c5491279ba69eb72d168ff7c6611437d4db96e868e5
7
+ data.tar.gz: 5e199bab324f5f1d6f6d28b0ffee43d5c0f649b46b019257760a5b05a2de0e325d1e8c387385bcb6402e21bb2f50bbdc69a54640ab96d97750fed5b17cef88dd
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2022 Andrew Culver
1
+ Copyright 2022 Bullet Train, Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -8,19 +8,24 @@ class Api::Base < Grape::API
8
8
  format :jsonapi
9
9
  default_error_formatter :json
10
10
 
11
- # TODO Shouldn't this be in V1 or not versioned?
12
- include Api::V1::ExceptionsHandler
13
-
14
11
  mount Api::V1::Root
15
12
 
16
- # Swagger docs are available at `/api/swagger_doc.json`.
13
+ # Swagger docs are available at `/api/docs/swagger.json`.
17
14
  add_swagger_documentation \
18
- hide_documentation_path: true,
19
- array_use_braces: true,
20
15
  api_version: "v1",
16
+ array_use_braces: true,
17
+ base_path: "/api",
18
+ doc_version: "1.0",
19
+ endpoint_auth_wrapper: ::WineBouncer::OAuth2,
20
+ hide_documentation_path: true,
21
21
  info: {
22
22
  title: I18n.t("application.name"),
23
23
  description: I18n.t("application.description")
24
24
  },
25
- endpoint_auth_wrapper: WineBouncer::OAuth2
25
+ mount_path: "/docs/swagger"
26
+
27
+ # TODO Reintroduce this once we've got `context` in current attributes.
28
+ # before do
29
+ # Current.context = :api
30
+ # end
26
31
  end
@@ -0,0 +1,42 @@
1
+ class Api::ModelParser < GrapeSwagger::Jsonapi::Parser
2
+ attr_reader :model, :endpoint
3
+
4
+ alias_method :schema, :call
5
+
6
+ def initialize(model, endpoint)
7
+ @model = model
8
+ @endpoint = endpoint
9
+ end
10
+
11
+ def call
12
+ # first let's grab the schema generated by the JSON:API parser
13
+ schema_json = schema.to_json
14
+
15
+ # From Nick Schneble:
16
+
17
+ # we can easily override these types for our API endpoints in the documentation
18
+ # but we can't do the same thing for the relationship objects that are auto-generated
19
+ # thus the fancy affair below
20
+
21
+ # if you want to learn more about what's happening here, read these:
22
+ # https://stackoverflow.com/a/17918118/1322386
23
+ # https://swagger.io/docs/specification/data-models/data-types/
24
+
25
+ # Swagger 3.0 only supports a subset of Ruby data types
26
+ schema_json.gsub!("\"type\":\"binary\"", "\"type\":\"string\", \"format\":\"binary\"")
27
+ schema_json.gsub!("\"type\":\"date\"", "\"type\":\"string\", \"format\":\"date\"")
28
+ schema_json.gsub!("\"type\":\"datetime\"", "\"type\":\"string\", \"format\":\"date-time\"")
29
+ schema_json.gsub!("\"type\":\"decimal\"", "\"type\":\"number\", \"format\":\"double\"")
30
+ schema_json.gsub!("\"type\":\"float\"", "\"type\":\"number\", \"format\":\"float\"")
31
+ schema_json.gsub!("\"type\":\"bigint\"", "\"type\":\"integer\", \"format\":\"int64\"")
32
+ schema_json.gsub!("\"type\":\"primary_key\"", "\"type\":\"integer\", \"format\":\"int64\"")
33
+ schema_json.gsub!("\"type\":\"references\"", "\"type\":\"object\"")
34
+ schema_json.gsub!("\"type\":\"text\"", "\"type\":\"string\"")
35
+ schema_json.gsub!("\"type\":\"time\"", "\"type\":\"string\", \"format\":\"time\"")
36
+ schema_json.gsub!("\"type\":\"timestamp\"", "\"type\":\"string\", \"format\":\"timestamp\"")
37
+ schema_json.gsub!("\"type\":\"json\"", "\"type\":\"array\", \"items\":{\"type\":\"string\"}")
38
+
39
+ # returns a Hash as if nothing fancy happened
40
+ JSON.parse(schema_json)
41
+ end
42
+ end
@@ -4,9 +4,11 @@ module Api::V1::Base
4
4
  included do
5
5
  include Api::V1::Defaults
6
6
  include Api::V1::LoadsAndAuthorizesApiResource
7
+ include Api::V1::ExceptionsHandler
7
8
 
8
9
  version "v1"
9
- use ::WineBouncer::OAuth2
10
+
11
+ use ::WineBouncer::OAuth2, message: "Doorkeeper OAuth2 Authentication"
10
12
 
11
13
  rescue_from :all do |error|
12
14
  handle_api_error(error)
@@ -15,6 +17,11 @@ module Api::V1::Base
15
17
  BulletTrain::Api.endpoints.each do |endpoint_class|
16
18
  mount endpoint_class.constantize
17
19
  end
20
+
21
+ after_validation do
22
+ # Ensure responses never get cached.
23
+ header "Cache-Control", "no-store"
24
+ end
18
25
  end
19
26
 
20
27
  class_methods do
@@ -16,7 +16,7 @@ module Api::V1::Teams::EndpointBase
16
16
  # `Api::V1::TeamsEndpoint`, but since we can get the latter, we'll use that to fetch whatever proc is defined
17
17
  # in ADDITIONAL_PARAMS.
18
18
  if defined?(@api.to_s.constantize::PARAMS)
19
- instance_eval &@api.to_s.constantize::PARAMS
19
+ instance_eval(&@api.to_s.constantize::PARAMS)
20
20
  end
21
21
  end
22
22
  end
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Api
3
- VERSION = "1.0.12"
3
+ VERSION = "1.0.13"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-04 00:00:00.000000000 Z
11
+ date: 2022-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: standard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +178,20 @@ dependencies:
164
178
  - - ">="
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: bullet_train
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :runtime
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
167
195
  description: Bullet Train API
168
196
  email:
169
197
  - andrew.culver@gmail.com
@@ -178,6 +206,7 @@ files:
178
206
  - app/controllers/account/platform/applications_controller.rb
179
207
  - app/controllers/api.rb
180
208
  - app/controllers/api/base.rb
209
+ - app/controllers/api/model_parser.rb
181
210
  - app/controllers/api/v1.rb
182
211
  - app/controllers/api/v1/defaults.rb
183
212
  - app/controllers/api/v1/exceptions_handler.rb