bullet_train-api 1.0.12 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/app/controllers/api/base.rb +12 -7
- data/app/controllers/api/model_parser.rb +42 -0
- data/app/controllers/api/v1/me_endpoint.rb +4 -3
- data/app/controllers/concerns/api/v1/base.rb +8 -1
- data/app/controllers/concerns/api/v1/teams/endpoint_base.rb +1 -1
- data/config/locales/en/me.en.yml +5 -0
- data/lib/bullet_train/api/engine.rb +1 -1
- data/lib/bullet_train/api/version.rb +1 -1
- data/lib/bullet_train/api.rb +1 -1
- metadata +38 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e93441de2a659f5a8f2bbac21638ff1ee591e508bf95aa89e356cbd9146cfa14
|
4
|
+
data.tar.gz: e1a0120f64880dac83f704c1f161076c6ac6343b2e42535f24d60e76dbb210f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17b8ee23d486ec26488bb40b0ef3b80a4b2b5c1f900d4016e0af457b593f5caecf5daf45dc529cc86a0240b292f5c469552ea6a0398417c5e83d6c946de190ef
|
7
|
+
data.tar.gz: ed4a3e521703d43e2c13e5015cfe116fa669edaa7fc45ceec08b6ae4171ef0eb9c79cf833a6c000234c5df8b418373a63066534f868beded9a878d52c43516be
|
data/MIT-LICENSE
CHANGED
data/app/controllers/api/base.rb
CHANGED
@@ -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/
|
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
|
-
|
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
|
@@ -1,8 +1,9 @@
|
|
1
1
|
class Api::V1::MeEndpoint < Api::V1::Root
|
2
|
-
resource :me do
|
2
|
+
resource :me, desc: Api.title(:actions) do
|
3
|
+
desc Api.title(:show), &Api.show_desc
|
3
4
|
oauth2
|
4
|
-
get
|
5
|
-
render
|
5
|
+
get do
|
6
|
+
render current_user, include: [:teams, :memberships], serializer: "Api::V1::UserSerializer", adapter: :attributes
|
6
7
|
end
|
7
8
|
end
|
8
9
|
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
|
-
|
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
|
19
|
+
instance_eval(&@api.to_s.constantize::PARAMS)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/bullet_train/api.rb
CHANGED
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.
|
4
|
+
version: 1.0.15
|
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-
|
11
|
+
date: 2022-05-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
|
@@ -56,16 +70,16 @@ dependencies:
|
|
56
70
|
name: grape-jsonapi
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - '='
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
75
|
+
version: 1.0.0
|
62
76
|
type: :runtime
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - '='
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 1.0.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: grape-swagger
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -95,7 +109,7 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: pagy
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - ">="
|
@@ -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
|
@@ -207,6 +236,7 @@ files:
|
|
207
236
|
- app/views/account/platform/applications/show.html.erb
|
208
237
|
- app/views/account/platform/applications/show.json.jbuilder
|
209
238
|
- config/locales/en/api.en.yml
|
239
|
+
- config/locales/en/me.en.yml
|
210
240
|
- config/locales/en/platform/applications.en.yml
|
211
241
|
- config/routes.rb
|
212
242
|
- lib/bullet_train/api.rb
|
@@ -234,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
234
264
|
- !ruby/object:Gem::Version
|
235
265
|
version: '0'
|
236
266
|
requirements: []
|
237
|
-
rubygems_version: 3.
|
267
|
+
rubygems_version: 3.3.7
|
238
268
|
signing_key:
|
239
269
|
specification_version: 4
|
240
270
|
summary: Bullet Train API
|