Skip to content

Commit 70b95f1

Browse files
committed
(#820) Deduplicate Swagger defs and add missing ones
1 parent 2c40721 commit 70b95f1

File tree

7 files changed

+201
-399
lines changed

7 files changed

+201
-399
lines changed

lib/swagger_docs.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ class SwaggerDocs
1919
include Models
2020
include Sections::General
2121
include Sections::Admin
22-
include Sections::Schemas
22+
include Sections::DescriptionSets
2323
include Sections::Envelopes
2424
include Sections::Graphs
25+
include Sections::Indexer
2526
include Sections::Resources
27+
include Sections::Schemas
2628
include Sections::Search
27-
include Sections::DescriptionSets
28-
include Sections::Indexer
2929

3030
swagger_root do
3131
key :swagger, '2.0'

lib/swagger_docs/sections/description_sets.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ module DescriptionSets # rubocop:todo Style/Documentation
55
extend ActiveSupport::Concern
66

77
included do
8-
swagger_path '/description_sets' do
8+
swagger_path '/{community_name}/description_sets' do
99
operation :post do
1010
key :operationId, 'postDescriptionSets'
1111
key :description, 'Returns the description sets for the given CTIDs'
1212
key :produces, ['application/json']
1313
key :tags, ['Description sets']
1414

15+
parameter community_name
16+
1517
parameter do
1618
key :name, :body
1719
key :in, :body
@@ -29,13 +31,14 @@ module DescriptionSets # rubocop:todo Style/Documentation
2931
end
3032
end
3133

32-
swagger_path '/description_sets/{ctid}' do
34+
swagger_path '/{community_name}/description_sets/{ctid}' do
3335
operation :get do # rubocop:todo Metrics/BlockLength
3436
key :operationId, 'getDescriptionSets'
3537
key :description, "Returns the given resource's description sets"
3638
key :produces, ['application/json']
3739
key :tags, ['Description sets']
3840

41+
parameter community_name
3942
parameter ctid(description: 'The CTID of the resource')
4043
parameter name: :limit,
4144
in: :query,

lib/swagger_docs/sections/envelopes.rb

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -112,52 +112,55 @@ module Envelopes # rubocop:todo Metrics/ModuleLength, Style/Documentation
112112
end
113113
end
114114

115-
swagger_path '/{community_name}/envelopes/info' do
116-
operation :get do
117-
key :operationId, 'getApiEnvelopesInfo'
118-
key :description, 'Gives general info about this community envelopes'
115+
swagger_path '/{community_name}/envelopes/downloads' do
116+
operation :post do
117+
key :operationId, 'postApiEnvelopesDownloads'
118+
key :description, 'Starts new download'
119119
key :produces, ['application/json']
120120
key :tags, ['Envelopes']
121121

122122
parameter community_name
123123

124-
response 200 do
125-
key :description, 'Gives general info about this community envelopes'
126-
schema { key :$ref, :EnvelopesInfo }
124+
response 201 do
125+
key :description, 'Download object'
126+
schema { key :$ref, :EnvelopeDownload }
127127
end
128128
end
129129
end
130130

131-
swagger_path '/{community_name}/envelopes/{envelope_id}/verify' do
132-
operation :patch do
133-
key :operationId, 'patchApiVerifyEnvelope'
134-
key :description, 'Updates verification date'
131+
swagger_path '/{community_name}/envelopes/downloads/{id}' do
132+
operation :get do
133+
key :operationId, 'getApiEnvelopesDownloads'
134+
key :description, "Returns download's status and URL"
135135
key :produces, ['application/json']
136136
key :tags, ['Envelopes']
137137

138138
parameter community_name
139-
parameter envelope_id
140-
141-
parameter do
142-
key :name, :body
143-
key :in, :body
144-
key :description, 'JSON object containing last_verified_on'
145-
key :required, true
139+
parameter name: :id,
140+
in: :path,
141+
type: :string,
142+
required: true,
143+
description: 'Download ID'
146144

147-
schema do
148-
key :type, :object
149-
property :last_verified_on do
150-
key :type, :string
151-
key :format, :date
152-
key :description, 'Last verification date'
153-
key :example, '2023-07-20'
154-
end
155-
end
145+
response 200 do
146+
key :description, 'Download object'
147+
schema { key :$ref, :EnvelopeDownload }
156148
end
149+
end
150+
end
151+
152+
swagger_path '/{community_name}/envelopes/info' do
153+
operation :get do
154+
key :operationId, 'getApiEnvelopesInfo'
155+
key :description, 'Gives general info about this community envelopes'
156+
key :produces, ['application/json']
157+
key :tags, ['Envelopes']
158+
159+
parameter community_name
157160

158161
response 200 do
159-
key :description, 'Retrieves a specific envelope revision'
160-
schema { key :$ref, :Envelope }
162+
key :description, 'Gives general info about this community envelopes'
163+
schema { key :$ref, :EnvelopesInfo }
161164
end
162165
end
163166
end
@@ -238,58 +241,55 @@ module Envelopes # rubocop:todo Metrics/ModuleLength, Style/Documentation
238241
end
239242
end
240243

241-
swagger_path '/{community_name}/envelopes/downloads' do
242-
operation :post do
243-
key :operationId, 'postApiEnvelopesDownloads'
244-
key :description, 'Starts new download'
245-
key :produces, ['application/json']
246-
key :tags, ['Envelopes']
247-
248-
parameter community_name
249-
250-
response 201 do
251-
key :description, 'Download object'
252-
schema { key :$ref, :EnvelopeDownload }
253-
end
254-
end
255-
end
256-
257-
swagger_path '/{community_name}/envelopes/downloads/{id}' do
244+
swagger_path '/{community_name}/envelopes/{envelope_id}/revisions/{revision_id}' do
258245
operation :get do
259-
key :operationId, 'getApiEnvelopesDownloads'
260-
key :description, "Returns download's status and URL"
246+
key :operationId, 'getApiEnvelopeVersion'
247+
key :description, 'Retrieves a specific envelope revision'
261248
key :produces, ['application/json']
262249
key :tags, ['Envelopes']
263250

264251
parameter community_name
265-
parameter name: :id,
252+
parameter envelope_id
253+
parameter include_deleted
254+
parameter name: :revision_id,
266255
in: :path,
267256
type: :string,
268257
required: true,
269-
description: 'Download ID'
258+
description: 'Unique revision identifier'
270259

271260
response 200 do
272-
key :description, 'Download object'
273-
schema { key :$ref, :EnvelopeDownload }
261+
key :description, 'Retrieves a specific envelope revision'
262+
schema { key :$ref, :Envelope }
274263
end
275264
end
276265
end
277266

278-
swagger_path '/{community_name}/envelopes/{envelope_id}/revisions/{revision_id}' do
279-
operation :get do
280-
key :operationId, 'getApiEnvelopeVersion'
281-
key :description, 'Retrieves a specific envelope revision'
267+
swagger_path '/{community_name}/envelopes/{envelope_id}/verify' do
268+
operation :patch do
269+
key :operationId, 'patchApiVerifyEnvelope'
270+
key :description, 'Updates verification date'
282271
key :produces, ['application/json']
283272
key :tags, ['Envelopes']
284273

285274
parameter community_name
286275
parameter envelope_id
287-
parameter include_deleted
288-
parameter name: :revision_id,
289-
in: :path,
290-
type: :string,
291-
required: true,
292-
description: 'Unique revision identifier'
276+
277+
parameter do
278+
key :name, :body
279+
key :in, :body
280+
key :description, 'JSON object containing last_verified_on'
281+
key :required, true
282+
283+
schema do
284+
key :type, :object
285+
property :last_verified_on do
286+
key :type, :string
287+
key :format, :date
288+
key :description, 'Last verification date'
289+
key :example, '2023-07-20'
290+
end
291+
end
292+
end
293293

294294
response 200 do
295295
key :description, 'Retrieves a specific envelope revision'

lib/swagger_docs/sections/graphs.rb

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,15 @@ module Graphs # rubocop:todo Style/Documentation
55
extend ActiveSupport::Concern
66

77
included do
8-
swagger_path '/graph/{resource_id}' do
9-
operation :get do
10-
key :operationId, 'getApiResourceGraph'
11-
key :description, 'Retrieves a resource by identifier. If the resource' \
12-
'is part of a graph, the entire graph is returned.'
13-
key :produces, ['application/json']
14-
key :tags, ['Graphs']
15-
16-
parameter resource_id
17-
18-
response 200 do
19-
key :description, 'Retrieves a resource by identifier'
20-
schema do
21-
key :description, 'Refer to the JSON Schema of your desired ' \
22-
'community for the resource specification.'
23-
key :type, :object
24-
end
25-
end
26-
end
27-
end
28-
29-
swagger_path '/{community_name}/graph/{resource_id}' do
30-
operation :get do
31-
key :operationId, 'getApiCommunityResourceGraph'
32-
key :description, 'Retrieves a resource by identifier. If the resource' \
33-
'is part of a graph, the entire graph is returned.'
34-
key :produces, ['application/json']
35-
key :tags, ['Graphs']
36-
37-
parameter community_name
38-
parameter resource_id
39-
40-
response 200 do
41-
key :description, 'Retrieves a resource by identifier'
42-
end
43-
end
44-
end
45-
46-
swagger_path '/graph/search' do
8+
swagger_path '/{community_name}/graph/search' do
479
operation :post do # rubocop:todo Metrics/BlockLength
4810
key :operationId, 'postApiGraphSearch'
4911
key :description, 'Retrieves graphs by the given CTIDs'
5012
key :produces, ['application/json']
5113
key :tags, ['Graphs']
5214

15+
parameter community_name
16+
5317
parameter do
5418
key :name, :body
5519
key :in, :body
@@ -83,6 +47,23 @@ module Graphs # rubocop:todo Style/Documentation
8347
end
8448
end
8549
end
50+
51+
swagger_path '/{community_name}/graph/{resource_id}' do
52+
operation :get do
53+
key :operationId, 'getApiGraphResource'
54+
key :description, 'Retrieves a resource by identifier. If the resource' \
55+
'is part of a graph, the entire graph is returned.'
56+
key :produces, ['application/json']
57+
key :tags, ['Graphs']
58+
59+
parameter community_name
60+
parameter resource_id
61+
62+
response 200 do
63+
key :description, 'Retrieves a resource by identifier'
64+
end
65+
end
66+
end
8667
end
8768
end
8869
end

lib/swagger_docs/sections/indexer.rb

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,6 @@ module Indexer # rubocop:todo Style/Documentation
2121
end
2222
end
2323

24-
swagger_path '/indexed_resources/{ctid}' do
25-
operation :get do
26-
key :operationId, 'getApiIndexedResource'
27-
key :description, 'Retrieve an indexed resource by its CTID'
28-
key :produces, ['application/json']
29-
key :tags, ['Indexer']
30-
31-
parameter ctid(description: 'The CTID of the indexed resource')
32-
33-
response 200 do
34-
key :description, 'Indexed resource'
35-
key :type, :object
36-
end
37-
end
38-
end
39-
40-
swagger_path '/indexer/stats' do
41-
operation :get do
42-
key :operationId, 'getApiIndexerStats'
43-
key :description, 'Shows how many indexing jobs are in the queue'
44-
key :produces, ['application/json']
45-
key :tags, ['Indexer']
46-
47-
response 200 do
48-
key :description, 'Indexer stats'
49-
schema do
50-
property :enqueued_jobs,
51-
type: :number,
52-
description: 'Number of indexing jobs waiting in the queue'
53-
property :in_progress_jobs,
54-
type: :number,
55-
description: 'Number of indexing jobs in progress'
56-
end
57-
end
58-
end
59-
end
60-
6124
swagger_path '/{community_name}/indexed_resources/{ctid}' do
6225
operation :get do
6326
key :operationId, 'getApiIndexedResourceByCommunity'

0 commit comments

Comments
 (0)