bullet_train-api 1.1.9 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/open_api_controller.rb +2 -2
- data/app/controllers/concerns/api/controllers/base.rb +36 -3
- data/app/views/api/v1/open_api/shared/_paths.yaml.erb +4 -4
- data/app/views/api/v1/open_api/teams/_paths.yaml.erb +4 -4
- data/app/views/api/v1/open_api/users/_paths.yaml.erb +3 -3
- data/app/views/api/v1/platform/access_tokens/index.json.jbuilder +1 -5
- data/app/views/api/v1/teams/index.json.jbuilder +1 -5
- data/app/views/api/v1/users/index.json.jbuilder +1 -5
- data/app/views/api/v2/open_api/shared/_paths.yaml.erb +108 -0
- data/app/views/api/v2/open_api/teams/_paths.yaml.erb +55 -0
- data/app/views/api/v2/open_api/users/_paths.yaml.erb +55 -0
- data/app/views/api/v2/platform/access_tokens/_access_token.json.jbuilder +10 -0
- data/app/views/api/v2/platform/access_tokens/index.json.jbuilder +1 -0
- data/app/views/api/v2/platform/access_tokens/show.json.jbuilder +1 -0
- data/app/views/api/v2/teams/index.json.jbuilder +1 -0
- data/app/views/api/v2/teams/show.json.jbuilder +1 -0
- data/app/views/api/v2/users/index.json.jbuilder +1 -0
- data/app/views/api/v2/users/show.json.jbuilder +1 -0
- data/config/routes.rb +11 -9
- data/lib/bullet_train/api/version.rb +1 -1
- data/lib/bullet_train/api.rb +13 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 807f6397b8ca4d3ed29c7181d9aa72456630ad6262baeab928637f11858d83f1
|
4
|
+
data.tar.gz: d3db30ae44aa54f4504554a10eadd3570c061a558068b9dba844580bb8fb1b7d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e748b8c2207bc0a43e8cbacfb69e48108fff664298404194299fafa5271d5b330222830bedce8351916096430ef42d83ea9b4af96c647abc9f4996e9e73194f8
|
7
|
+
data.tar.gz: 702abad5b373fe2600f460c26c363a2063082e9cd9fb832b9991d7bf079ba40175e0eba8ef25f2f4a3bf0f9e4b46026e83b1383144cafb0c20789a8c0c7574e2
|
@@ -60,8 +60,8 @@ module OpenApiHelper
|
|
60
60
|
parameters_output["properties"].select! { |key, value| strong_parameter_keys.include?(key.to_sym) }
|
61
61
|
|
62
62
|
(
|
63
|
-
indent(attributes_output.to_yaml.gsub("---", "#{model.name}
|
64
|
-
indent(" " + parameters_output.to_yaml.gsub("---", "#{model.name}
|
63
|
+
indent(attributes_output.to_yaml.gsub("---", "#{model.name.gsub("::", "")}Attributes:"), 3) +
|
64
|
+
indent(" " + parameters_output.to_yaml.gsub("---", "#{model.name.gsub("::", "")}Parameters:"), 3)
|
65
65
|
).html_safe
|
66
66
|
end
|
67
67
|
|
@@ -17,6 +17,30 @@ module Api::Controllers::Base
|
|
17
17
|
|
18
18
|
before_action :set_default_response_format
|
19
19
|
before_action :doorkeeper_authorize!
|
20
|
+
after_action :set_pagination_headers
|
21
|
+
|
22
|
+
def modify_url_params(url, new_params)
|
23
|
+
uri = URI.parse(url)
|
24
|
+
query = Rack::Utils.parse_query(uri.query)
|
25
|
+
new_params.each do |key, value|
|
26
|
+
query[key] = value
|
27
|
+
end
|
28
|
+
uri.query = Rack::Utils.build_query(query)
|
29
|
+
uri.to_s
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_pagination_headers
|
33
|
+
return unless @pagy
|
34
|
+
|
35
|
+
if @pagy.has_more?
|
36
|
+
if (collection = instance_variable_get(collection_variable))
|
37
|
+
next_cursor = collection.last.id
|
38
|
+
# TODO Probably not great that we're clobbering any `Link` header that might be set.
|
39
|
+
response.headers["Link"] = "<#{modify_url_params(request.url, after: next_cursor)}>; rel=next"
|
40
|
+
response.headers["Pagination-Next"] = next_cursor
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
20
44
|
|
21
45
|
rescue_from CanCan::AccessDenied, ActiveRecord::RecordNotFound do |exception|
|
22
46
|
render json: {error: "Not found"}, status: :not_found
|
@@ -42,7 +66,13 @@ module Api::Controllers::Base
|
|
42
66
|
|
43
67
|
def current_user
|
44
68
|
raise NotAuthenticatedError unless doorkeeper_token.present?
|
45
|
-
|
69
|
+
# TODO Remove this rescue once workspace clusters can write to this column on the identity server.
|
70
|
+
# TODO Make this logic configurable so that downstream developers can write different methods for this column getting updated.
|
71
|
+
begin
|
72
|
+
doorkeeper_token.update(last_used_at: Time.zone.now)
|
73
|
+
rescue
|
74
|
+
ActiveRecord::StatementInvalid
|
75
|
+
end
|
46
76
|
@current_user ||= User.find_by(id: doorkeeper_token[:resource_owner_id])
|
47
77
|
end
|
48
78
|
|
@@ -51,10 +81,13 @@ module Api::Controllers::Base
|
|
51
81
|
current_user&.teams&.first
|
52
82
|
end
|
53
83
|
|
84
|
+
def collection_variable
|
85
|
+
@collection_variable ||= "@#{self.class.name.split("::").last.gsub("Controller", "").underscore}"
|
86
|
+
end
|
87
|
+
|
54
88
|
def apply_pagination
|
55
|
-
collection_variable = "@#{self.class.name.split("::").last.gsub("Controller", "").underscore}"
|
56
89
|
collection = instance_variable_get collection_variable
|
57
|
-
@pagy, collection = pagy_cursor collection
|
90
|
+
@pagy, collection = pagy_cursor collection, after: params[:after]
|
58
91
|
instance_variable_set collection_variable, collection
|
59
92
|
end
|
60
93
|
|
@@ -26,7 +26,7 @@
|
|
26
26
|
data:
|
27
27
|
type: array
|
28
28
|
items:
|
29
|
-
$ref: "#/components/schemas/
|
29
|
+
$ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingAttributes"
|
30
30
|
has_more:
|
31
31
|
type: boolean
|
32
32
|
<% end %>
|
@@ -50,7 +50,7 @@
|
|
50
50
|
content:
|
51
51
|
application/json:
|
52
52
|
schema:
|
53
|
-
$ref: "#/components/schemas/
|
53
|
+
$ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingParameters"
|
54
54
|
<% end %>
|
55
55
|
<% end %>
|
56
56
|
<% unless except.include?(:show) && except.include?(:update) && except.include?(:destroy) %>
|
@@ -71,7 +71,7 @@
|
|
71
71
|
content:
|
72
72
|
application/json:
|
73
73
|
schema:
|
74
|
-
$ref: "#/components/schemas/
|
74
|
+
$ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingAttributes"
|
75
75
|
<% end %>
|
76
76
|
<% unless except.include?(:update) %>
|
77
77
|
put:
|
@@ -89,7 +89,7 @@
|
|
89
89
|
content:
|
90
90
|
application/json:
|
91
91
|
schema:
|
92
|
-
$ref: "#/components/schemas/
|
92
|
+
$ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingParameters"
|
93
93
|
<% end %>
|
94
94
|
<% unless except.include?(:destroy) %>
|
95
95
|
delete:
|
@@ -16,8 +16,8 @@
|
|
16
16
|
properties:
|
17
17
|
data:
|
18
18
|
type: array
|
19
|
-
items:
|
20
|
-
$ref: "#/components/schemas/
|
19
|
+
items:
|
20
|
+
$ref: "#/components/schemas/TeamAttributes"
|
21
21
|
has_more:
|
22
22
|
type: boolean
|
23
23
|
/teams/{id}:
|
@@ -36,7 +36,7 @@
|
|
36
36
|
content:
|
37
37
|
application/json:
|
38
38
|
schema:
|
39
|
-
$ref: "#/components/schemas/
|
39
|
+
$ref: "#/components/schemas/TeamAttributes"
|
40
40
|
put:
|
41
41
|
tags:
|
42
42
|
- Teams
|
@@ -52,4 +52,4 @@
|
|
52
52
|
content:
|
53
53
|
application/json:
|
54
54
|
schema:
|
55
|
-
$ref: "#/components/schemas/
|
55
|
+
$ref: "#/components/schemas/TeamParameters"
|
@@ -17,7 +17,7 @@
|
|
17
17
|
data:
|
18
18
|
type: array
|
19
19
|
items:
|
20
|
-
$ref: "#/components/schemas/
|
20
|
+
$ref: "#/components/schemas/UserAttributes"
|
21
21
|
has_more:
|
22
22
|
type: boolean
|
23
23
|
/users/{id}:
|
@@ -36,7 +36,7 @@
|
|
36
36
|
content:
|
37
37
|
application/json:
|
38
38
|
schema:
|
39
|
-
$ref: "#/components/schemas/
|
39
|
+
$ref: "#/components/schemas/UserAttributes"
|
40
40
|
put:
|
41
41
|
tags:
|
42
42
|
- Users
|
@@ -52,4 +52,4 @@
|
|
52
52
|
content:
|
53
53
|
application/json:
|
54
54
|
schema:
|
55
|
-
$ref: "#/components/schemas/
|
55
|
+
$ref: "#/components/schemas/UserParameters"
|
@@ -0,0 +1,108 @@
|
|
1
|
+
<% except ||= [] %>
|
2
|
+
<% unless except.include?(:index) && except.include?(:create) %>
|
3
|
+
/scaffolding/absolutely_abstract/creative_concepts/{absolutely_abstract_creative_concept_id}/completely_concrete/tangible_things:
|
4
|
+
<% unless except.include?(:index) %>
|
5
|
+
get:
|
6
|
+
tags:
|
7
|
+
- "Scaffolding/Completely Concrete/Tangible Things"
|
8
|
+
summary: "List Tangible Things"
|
9
|
+
operationId: listScaffoldingCompletelyConcreteTangibleThings
|
10
|
+
parameters:
|
11
|
+
- name: absolutely_abstract_creative_concept_id
|
12
|
+
in: path
|
13
|
+
required: true
|
14
|
+
schema:
|
15
|
+
type: string
|
16
|
+
responses:
|
17
|
+
"404":
|
18
|
+
description: "Not Found"
|
19
|
+
"200":
|
20
|
+
description: "OK"
|
21
|
+
content:
|
22
|
+
application/json:
|
23
|
+
schema:
|
24
|
+
type: object
|
25
|
+
properties:
|
26
|
+
data:
|
27
|
+
type: array
|
28
|
+
items:
|
29
|
+
$ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingAttributes"
|
30
|
+
has_more:
|
31
|
+
type: boolean
|
32
|
+
<% end %>
|
33
|
+
<% unless except.include?(:create) %>
|
34
|
+
post:
|
35
|
+
tags:
|
36
|
+
- "Scaffolding/Completely Concrete/Tangible Things"
|
37
|
+
summary: "Create Tangible Thing"
|
38
|
+
operationId: createScaffoldingCompletelyConcreteTangibleThings
|
39
|
+
parameters:
|
40
|
+
- name: absolutely_abstract_creative_concept_id
|
41
|
+
in: path
|
42
|
+
required: true
|
43
|
+
schema:
|
44
|
+
type: string
|
45
|
+
responses:
|
46
|
+
"404":
|
47
|
+
description: "Not Found"
|
48
|
+
"201":
|
49
|
+
description: "Created"
|
50
|
+
content:
|
51
|
+
application/json:
|
52
|
+
schema:
|
53
|
+
$ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingParameters"
|
54
|
+
<% end %>
|
55
|
+
<% end %>
|
56
|
+
<% unless except.include?(:show) && except.include?(:update) && except.include?(:destroy) %>
|
57
|
+
/scaffolding/completely_concrete/tangible_things/{id}:
|
58
|
+
<% unless except.include?(:show) %>
|
59
|
+
get:
|
60
|
+
tags:
|
61
|
+
- "Scaffolding/Completely Concrete/Tangible Things"
|
62
|
+
summary: "Fetch Tangible Thing"
|
63
|
+
operationId: getScaffoldingCompletelyConcreteTangibleThings
|
64
|
+
parameters:
|
65
|
+
- $ref: "#/components/parameters/id"
|
66
|
+
responses:
|
67
|
+
"404":
|
68
|
+
description: "Not Found"
|
69
|
+
"200":
|
70
|
+
description: "OK"
|
71
|
+
content:
|
72
|
+
application/json:
|
73
|
+
schema:
|
74
|
+
$ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingAttributes"
|
75
|
+
<% end %>
|
76
|
+
<% unless except.include?(:update) %>
|
77
|
+
put:
|
78
|
+
tags:
|
79
|
+
- "Scaffolding/Completely Concrete/Tangible Things"
|
80
|
+
summary: "Update Tangible Thing"
|
81
|
+
operationId: updateScaffoldingCompletelyConcreteTangibleThings
|
82
|
+
parameters:
|
83
|
+
- $ref: "#/components/parameters/id"
|
84
|
+
responses:
|
85
|
+
"404":
|
86
|
+
description: "Not Found"
|
87
|
+
"200":
|
88
|
+
description: "OK"
|
89
|
+
content:
|
90
|
+
application/json:
|
91
|
+
schema:
|
92
|
+
$ref: "#/components/schemas/ScaffoldingCompletelyConcreteTangibleThingParameters"
|
93
|
+
<% end %>
|
94
|
+
<% unless except.include?(:destroy) %>
|
95
|
+
delete:
|
96
|
+
tags:
|
97
|
+
- "Scaffolding/Completely Concrete/Tangible Things"
|
98
|
+
summary: "Remove Tangible Thing"
|
99
|
+
operationId: removeScaffoldingCompletelyConcreteTangibleThings
|
100
|
+
parameters:
|
101
|
+
- $ref: "#/components/parameters/id"
|
102
|
+
responses:
|
103
|
+
"404":
|
104
|
+
description: "Not Found"
|
105
|
+
"200":
|
106
|
+
description: "OK"
|
107
|
+
<% end %>
|
108
|
+
<% end %>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/teams:
|
2
|
+
get:
|
3
|
+
tags:
|
4
|
+
- Teams
|
5
|
+
summary: "List Teams"
|
6
|
+
operationId: listTeams
|
7
|
+
responses:
|
8
|
+
"404":
|
9
|
+
description: "Not Found"
|
10
|
+
"200":
|
11
|
+
description: "OK"
|
12
|
+
content:
|
13
|
+
application/json:
|
14
|
+
schema:
|
15
|
+
type: object
|
16
|
+
properties:
|
17
|
+
data:
|
18
|
+
type: array
|
19
|
+
items:
|
20
|
+
$ref: "#/components/schemas/TeamAttributes"
|
21
|
+
has_more:
|
22
|
+
type: boolean
|
23
|
+
/teams/{id}:
|
24
|
+
get:
|
25
|
+
tags:
|
26
|
+
- Teams
|
27
|
+
summary: "Fetch Team"
|
28
|
+
operationId: fetchTeam
|
29
|
+
parameters:
|
30
|
+
- $ref: "#/components/parameters/id"
|
31
|
+
responses:
|
32
|
+
"404":
|
33
|
+
description: "Not Found"
|
34
|
+
"200":
|
35
|
+
description: "OK"
|
36
|
+
content:
|
37
|
+
application/json:
|
38
|
+
schema:
|
39
|
+
$ref: "#/components/schemas/TeamAttributes"
|
40
|
+
put:
|
41
|
+
tags:
|
42
|
+
- Teams
|
43
|
+
summary: "Update Team"
|
44
|
+
operationId: updateTeam
|
45
|
+
parameters:
|
46
|
+
- $ref: "#/components/parameters/id"
|
47
|
+
responses:
|
48
|
+
"404":
|
49
|
+
description: "Not Found"
|
50
|
+
"200":
|
51
|
+
description: "OK"
|
52
|
+
content:
|
53
|
+
application/json:
|
54
|
+
schema:
|
55
|
+
$ref: "#/components/schemas/TeamParameters"
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/users:
|
2
|
+
get:
|
3
|
+
tags:
|
4
|
+
- Users
|
5
|
+
summary: "List Users"
|
6
|
+
operationId: listUsers
|
7
|
+
responses:
|
8
|
+
"404":
|
9
|
+
description: "Not Found"
|
10
|
+
"200":
|
11
|
+
description: "OK"
|
12
|
+
content:
|
13
|
+
application/json:
|
14
|
+
schema:
|
15
|
+
type: object
|
16
|
+
properties:
|
17
|
+
data:
|
18
|
+
type: array
|
19
|
+
items:
|
20
|
+
$ref: "#/components/schemas/UserAttributes"
|
21
|
+
has_more:
|
22
|
+
type: boolean
|
23
|
+
/users/{id}:
|
24
|
+
get:
|
25
|
+
tags:
|
26
|
+
- Users
|
27
|
+
summary: "Fetch User"
|
28
|
+
operationId: fetchUser
|
29
|
+
parameters:
|
30
|
+
- $ref: "#/components/parameters/id"
|
31
|
+
responses:
|
32
|
+
"404":
|
33
|
+
description: "Not Found"
|
34
|
+
"200":
|
35
|
+
description: "OK"
|
36
|
+
content:
|
37
|
+
application/json:
|
38
|
+
schema:
|
39
|
+
$ref: "#/components/schemas/UserAttributes"
|
40
|
+
put:
|
41
|
+
tags:
|
42
|
+
- Users
|
43
|
+
summary: "Update User"
|
44
|
+
operationId: updateUser
|
45
|
+
parameters:
|
46
|
+
- $ref: "#/components/parameters/id"
|
47
|
+
responses:
|
48
|
+
"404":
|
49
|
+
description: "Not Found"
|
50
|
+
"200":
|
51
|
+
description: "OK"
|
52
|
+
content:
|
53
|
+
application/json:
|
54
|
+
schema:
|
55
|
+
$ref: "#/components/schemas/UserParameters"
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @access_tokens, partial: "api/v2/platform/access_tokens/access_token", as: :access_token
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "api/v2/platform/access_tokens/access_token", access_token: @access_token
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @teams, partial: "api/v2/teams/team", as: :team
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "api/v2/teams/team", team: @team
|
@@ -0,0 +1 @@
|
|
1
|
+
json.array! @users, partial: "api/v2/users/user", as: :user
|
@@ -0,0 +1 @@
|
|
1
|
+
json.partial! "api/v2/users/user", user: @user
|
data/config/routes.rb
CHANGED
@@ -20,15 +20,17 @@ Rails.application.routes.draw do
|
|
20
20
|
namespace :api do
|
21
21
|
match "*version/openapi.yaml" => "open_api#index", :via => :get
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
resources :
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
resources :
|
23
|
+
BulletTrain::Api.all_versions.each do |version|
|
24
|
+
namespace version do
|
25
|
+
shallow do
|
26
|
+
resources :users
|
27
|
+
resources :teams do
|
28
|
+
resources :invitations
|
29
|
+
resources :memberships
|
30
|
+
namespace :platform do
|
31
|
+
resources :applications do
|
32
|
+
resources :access_tokens
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
34
36
|
end
|
data/lib/bullet_train/api.rb
CHANGED
@@ -16,5 +16,18 @@ module BulletTrain
|
|
16
16
|
module Api
|
17
17
|
mattr_accessor :endpoints, default: []
|
18
18
|
mattr_accessor :current_version, default: "v1"
|
19
|
+
mattr_accessor :initial_version, default: "v1"
|
20
|
+
|
21
|
+
def self.current_version_numeric
|
22
|
+
current_version.split("v").last.to_i
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.initial_version_numeric
|
26
|
+
initial_version.split("v").last.to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.all_versions
|
30
|
+
(initial_version_numeric..current_version_numeric).map { |version| "v#{version}".to_sym }
|
31
|
+
end
|
19
32
|
end
|
20
33
|
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.1.
|
4
|
+
version: 1.1.11
|
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-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -172,6 +172,16 @@ files:
|
|
172
172
|
- app/views/api/v1/teams/show.json.jbuilder
|
173
173
|
- app/views/api/v1/users/index.json.jbuilder
|
174
174
|
- app/views/api/v1/users/show.json.jbuilder
|
175
|
+
- app/views/api/v2/open_api/shared/_paths.yaml.erb
|
176
|
+
- app/views/api/v2/open_api/teams/_paths.yaml.erb
|
177
|
+
- app/views/api/v2/open_api/users/_paths.yaml.erb
|
178
|
+
- app/views/api/v2/platform/access_tokens/_access_token.json.jbuilder
|
179
|
+
- app/views/api/v2/platform/access_tokens/index.json.jbuilder
|
180
|
+
- app/views/api/v2/platform/access_tokens/show.json.jbuilder
|
181
|
+
- app/views/api/v2/teams/index.json.jbuilder
|
182
|
+
- app/views/api/v2/teams/show.json.jbuilder
|
183
|
+
- app/views/api/v2/users/index.json.jbuilder
|
184
|
+
- app/views/api/v2/users/show.json.jbuilder
|
175
185
|
- config/locales/en/api.en.yml
|
176
186
|
- config/locales/en/me.en.yml
|
177
187
|
- config/locales/en/platform/access_tokens.en.yml
|