bullet_train-api 1.1.3 → 1.1.6
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/controllers/api/open_api_controller.rb +59 -0
- data/app/views/api/v1/open_api/index.yaml.erb +29 -0
- data/app/views/api/v1/open_api/teams/_paths.yaml.erb +55 -0
- data/app/views/api/v1/open_api/users/_paths.yaml.erb +55 -0
- data/config/routes.rb +2 -0
- data/lib/bullet_train/api/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f474623bb0f011c89b57e3d4b0c6b8dbce5dc388772dfa5373155b2216a39b8e
|
4
|
+
data.tar.gz: cc167320a1f660301b3beab289db2fd29c2c6b72361d47c5276fe24a28f27eec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf49807aecaa0e1814fce504b214c41b6606f36dbd69814b520c45eb5ad7bf75af2b593befd2617cff8198572d0a0b3c8256f38aba78dcc5874cbae021939db5
|
7
|
+
data.tar.gz: 1ba92be181ff6faa0bbcfb0e480105e31222076d48bd213710200772403328492391a0247023cb0eff6f4c2b2e1d54f40a1dd8427d57d256ba2d5f91467bebff
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module OpenApiHelper
|
2
|
+
def indent(string, count)
|
3
|
+
lines = string.lines
|
4
|
+
first_line = lines.shift
|
5
|
+
lines = lines.map { |line| (" " * count).to_s + line }
|
6
|
+
lines.unshift(first_line).join.html_safe
|
7
|
+
end
|
8
|
+
|
9
|
+
def components_for(model)
|
10
|
+
for_model model do
|
11
|
+
indent(render("api/#{@version}/open_api/#{model.name.underscore.pluralize}/components"), 2)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def current_model
|
16
|
+
@model_stack.last
|
17
|
+
end
|
18
|
+
|
19
|
+
def for_model(model)
|
20
|
+
@model_stack ||= []
|
21
|
+
@model_stack << model
|
22
|
+
result = yield
|
23
|
+
@model_stack.pop
|
24
|
+
result
|
25
|
+
end
|
26
|
+
|
27
|
+
def paths_for(model)
|
28
|
+
for_model model do
|
29
|
+
indent(render("api/#{@version}/open_api/#{model.name.underscore.pluralize}/paths"), 1)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def attribute(attribute)
|
34
|
+
heading = t("#{current_model.name.underscore.pluralize}.fields.#{attribute}.heading")
|
35
|
+
# TODO A lot of logic to be done here.
|
36
|
+
indent("#{attribute}:\n description: \"#{heading}\"\n type: string", 2)
|
37
|
+
end
|
38
|
+
|
39
|
+
def parameter(attribute)
|
40
|
+
heading = t("#{current_model.name.underscore.pluralize}.fields.#{attribute}.heading")
|
41
|
+
# TODO A lot of logic to be done here.
|
42
|
+
indent("#{attribute}:\n description: \"#{heading}\"\n type: string", 2)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Api::OpenApiController < ApplicationController
|
47
|
+
helper :open_api
|
48
|
+
|
49
|
+
def set_default_response_format
|
50
|
+
request.format = :yaml
|
51
|
+
end
|
52
|
+
|
53
|
+
before_action :set_default_response_format
|
54
|
+
|
55
|
+
def index
|
56
|
+
@version = params[:version]
|
57
|
+
render "api/#{@version}/open_api/index", layout: nil, format: :text
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
openapi: 3.1.0
|
2
|
+
info:
|
3
|
+
title: Bullet Train API
|
4
|
+
description: |
|
5
|
+
The baseline API of a new Bullet Train application.
|
6
|
+
license:
|
7
|
+
name: MIT
|
8
|
+
url: https://opensource.org/licenses/MIT
|
9
|
+
version: "<%= @version.upcase %>"
|
10
|
+
servers:
|
11
|
+
- url: <%= ENV["BASE_URL"] %>/api/<%= @version %>
|
12
|
+
components:
|
13
|
+
schemas:
|
14
|
+
<%= components_for Team %>
|
15
|
+
<%= components_for User %>
|
16
|
+
<%= components_for Scaffolding::CompletelyConcrete::TangibleThing unless scaffolding_things_disabled? %>
|
17
|
+
<%# 🚅 super scaffolding will insert new components above this line. %>
|
18
|
+
parameters:
|
19
|
+
id:
|
20
|
+
name: id
|
21
|
+
in: path
|
22
|
+
required: true
|
23
|
+
schema:
|
24
|
+
type: string
|
25
|
+
paths:
|
26
|
+
<%= paths_for Team %>
|
27
|
+
<%= paths_for User %>
|
28
|
+
<%= paths_for Scaffolding::CompletelyConcrete::TangibleThing unless scaffolding_things_disabled? %>
|
29
|
+
<%# 🚅 super scaffolding will insert new paths above this line. %>
|
@@ -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/Team::Attributes"
|
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/Team::Attributes"
|
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/Team::Parameters"
|
@@ -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/User::Attributes"
|
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/User::Attributes"
|
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/User::Parameters"
|
data/config/routes.rb
CHANGED
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.6
|
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-09-
|
11
|
+
date: 2022-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- app/assets/config/bullet_train_api_manifest.js
|
123
123
|
- app/controllers/account/platform/access_tokens_controller.rb
|
124
124
|
- app/controllers/account/platform/applications_controller.rb
|
125
|
+
- app/controllers/api/open_api_controller.rb
|
125
126
|
- app/controllers/api/v1/platform/access_tokens_controller.rb
|
126
127
|
- app/controllers/concerns/api/controllers/base.rb
|
127
128
|
- app/controllers/concerns/api/v1/teams/controller_base.rb
|
@@ -147,6 +148,9 @@ files:
|
|
147
148
|
- app/views/account/platform/applications/new.html.erb
|
148
149
|
- app/views/account/platform/applications/show.html.erb
|
149
150
|
- app/views/account/platform/applications/show.json.jbuilder
|
151
|
+
- app/views/api/v1/open_api/index.yaml.erb
|
152
|
+
- app/views/api/v1/open_api/teams/_paths.yaml.erb
|
153
|
+
- app/views/api/v1/open_api/users/_paths.yaml.erb
|
150
154
|
- app/views/api/v1/platform/access_tokens/_access_token.json.jbuilder
|
151
155
|
- app/views/api/v1/platform/access_tokens/index.json.jbuilder
|
152
156
|
- app/views/api/v1/platform/access_tokens/show.json.jbuilder
|