Skip to content

Commit 4d5c8f1

Browse files
authored
Add default API header settings and opendocs (#49)
1 parent 77e8f2c commit 4d5c8f1

File tree

6 files changed

+391
-3
lines changed

6 files changed

+391
-3
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@
33
build:
44
go build -o ./bin/app ./src/cmd/app/main.go
55

6-
run:
6+
run:test
77
ifeq ($(OS),Windows_NT)
88
$env:GO_ENV="test"; go run ./src/cmd/app/main.go
99
else
1010
GO_ENV=test go run ./src/cmd/app/main.go
1111
endif
12+
13+
run:prod:
14+
ifeq ($(OS),Windows_NT)
15+
$env:GO_ENV="prod"; go run ./src/cmd/app/main.go
16+
else
17+
GO_ENV=prod go run ./src/cmd/app/main.go
18+
endif
1219

1320
test:
1421
go test -p 1 -v ./...

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ You might need to remove mongodb setting from docker-compose.yml if launching th
7171

7272
1. Clone the repository
7373
2. Configure the environment variables in the `.env.test` file
74-
3. `make run` to start the application
74+
3. `make run:test` to start the application
7575

7676
# Integrated tests
7777

resources/swagger.yaml

Lines changed: 348 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,348 @@
1+
openapi: 3.0.1
2+
info:
3+
title: Switcher GitOps
4+
version: v1.0.1
5+
description: GitOps Domain Snapshot Orchestrator for Switcher API.
6+
contact:
7+
name: Roger Floriano (petruki)
8+
9+
url: https://github.com/petruki
10+
license:
11+
name: MIT
12+
url: https://github.com/switcherapi/switcher-gitops/blob/master/LICENSE
13+
servers:
14+
- url: http://localhost:8000
15+
description: Local
16+
- url: https://localhost:8000
17+
description: Remote
18+
paths:
19+
/api/check:
20+
get:
21+
tags:
22+
- API
23+
summary: Check API status
24+
description: Check API status
25+
responses:
26+
'200':
27+
description: API status
28+
content:
29+
application/json:
30+
schema:
31+
type: object
32+
properties:
33+
status:
34+
type: string
35+
description: API status
36+
version:
37+
type: string
38+
description: API version
39+
release_time:
40+
type: string
41+
description: API last release date time
42+
api_settings:
43+
type: object
44+
properties:
45+
switcher_url:
46+
type: string
47+
description: Switcher API URL
48+
switcher_secret:
49+
type: boolean
50+
description: Has Switcher API secret
51+
git_token_secret:
52+
type: boolean
53+
description: Has Git token secret
54+
core_handler_status:
55+
type: boolean
56+
description: Core handler status (-1 Created, 0 Initialized, 1 Running)
57+
enum: [ "-1", "0", "1" ]
58+
num_goroutines:
59+
type: integer
60+
description: Number of goroutines running
61+
/account:
62+
post:
63+
tags:
64+
- Account API
65+
summary: Create a new account
66+
description: Create a new account and starts handler when active
67+
requestBody:
68+
required: true
69+
content:
70+
application/json:
71+
schema:
72+
$ref: '#/components/schemas/AccountRequest'
73+
responses:
74+
'201':
75+
description: Account created
76+
content:
77+
application/json:
78+
schema:
79+
$ref: '#/components/schemas/AccountResponse'
80+
'400':
81+
description: Invalid request
82+
content:
83+
application/json:
84+
schema:
85+
$ref: '#/components/schemas/ErrorResponse'
86+
'500':
87+
description: Error creating accoun
88+
content:
89+
application/json:
90+
schema:
91+
$ref: '#/components/schemas/ErrorResponse'
92+
put:
93+
tags:
94+
- Account API
95+
summary: Update an existing account
96+
description: Update an existing account and starts handler when active
97+
requestBody:
98+
required: true
99+
content:
100+
application/json:
101+
schema:
102+
$ref: '#/components/schemas/AccountRequest'
103+
responses:
104+
'200':
105+
description: Account updated
106+
content:
107+
application/json:
108+
schema:
109+
$ref: '#/components/schemas/AccountResponse'
110+
'400':
111+
description: Invalid request
112+
content:
113+
application/json:
114+
schema:
115+
$ref: '#/components/schemas/ErrorResponse'
116+
'500':
117+
description: Error updating account
118+
content:
119+
application/json:
120+
schema:
121+
$ref: '#/components/schemas/ErrorResponse'
122+
/account/{domainId}:
123+
get:
124+
tags:
125+
- Account API
126+
summary: Get All accounts by domain ID
127+
description: Get all accounts by domain ID
128+
parameters:
129+
- name: domainId
130+
in: path
131+
required: true
132+
description: Domain ID
133+
schema:
134+
type: string
135+
format: uuid
136+
responses:
137+
'200':
138+
description: Account list
139+
content:
140+
application/json:
141+
schema:
142+
type: array
143+
items:
144+
$ref: '#/components/schemas/AccountResponse'
145+
'404':
146+
description: Accounts not found
147+
content:
148+
application/json:
149+
schema:
150+
$ref: '#/components/schemas/ErrorResponse'
151+
'400':
152+
description: Invalid request
153+
content:
154+
application/json:
155+
schema:
156+
$ref: '#/components/schemas/ErrorResponse'
157+
'500':
158+
description: Error getting accounts
159+
content:
160+
application/json:
161+
schema:
162+
$ref: '#/components/schemas/ErrorResponse'
163+
/account/{domainId}/{environment}:
164+
get:
165+
tags:
166+
- Account API
167+
summary: Get account by domain ID and environment
168+
description: Get account by domain ID and environment
169+
parameters:
170+
- name: domainId
171+
in: path
172+
required: true
173+
description: Domain ID
174+
schema:
175+
type: string
176+
format: uuid
177+
- name: environment
178+
in: path
179+
required: true
180+
description: Environment name
181+
schema:
182+
type: string
183+
responses:
184+
'200':
185+
description: Account list
186+
content:
187+
application/json:
188+
schema:
189+
$ref: '#/components/schemas/AccountResponse'
190+
'404':
191+
description: Account not found
192+
content:
193+
application/json:
194+
schema:
195+
$ref: '#/components/schemas/ErrorResponse'
196+
'400':
197+
description: Invalid request
198+
content:
199+
application/json:
200+
schema:
201+
$ref: '#/components/schemas/ErrorResponse'
202+
'500':
203+
description: Error getting account
204+
content:
205+
application/json:
206+
schema:
207+
$ref: '#/components/schemas/ErrorResponse'
208+
delete:
209+
tags:
210+
- Account API
211+
summary: Delete account by domain ID and environment
212+
description: Delete account by domain ID and environment
213+
parameters:
214+
- name: domainId
215+
in: path
216+
required: true
217+
description: Domain ID
218+
schema:
219+
type: string
220+
format: uuid
221+
- name: environment
222+
in: path
223+
required: true
224+
description: Environment name
225+
schema:
226+
type: string
227+
responses:
228+
'204':
229+
description: Account deleted
230+
'400':
231+
description: Invalid request
232+
content:
233+
application/json:
234+
schema:
235+
$ref: '#/components/schemas/ErrorResponse'
236+
'500':
237+
description: Error deleting account
238+
content:
239+
application/json:
240+
schema:
241+
$ref: '#/components/schemas/ErrorResponse'
242+
components:
243+
schemas:
244+
AccountRequest:
245+
type: object
246+
properties:
247+
repository:
248+
type: string
249+
description: Git repository URL
250+
branch:
251+
type: string
252+
description: Git branch
253+
example: main
254+
token:
255+
type: string
256+
description: Git token
257+
environment:
258+
type: string
259+
description: Environment name
260+
example: default
261+
domain:
262+
type: object
263+
properties:
264+
id:
265+
type: string
266+
format: uuid
267+
description: Domain ID
268+
name:
269+
type: string
270+
description: Domain name
271+
settings:
272+
type: object
273+
properties:
274+
active:
275+
type: boolean
276+
description: Sync handler status
277+
window:
278+
type: string
279+
description: Sync window time (s, m, h)
280+
example: 1m
281+
forceprune:
282+
type: boolean
283+
description: Force delete elements from the API when true
284+
AccountResponse:
285+
type: object
286+
properties:
287+
_id:
288+
type: string
289+
format: uuid
290+
description: Account ID
291+
repository:
292+
type: string
293+
description: Git repository URL
294+
branch:
295+
type: string
296+
description: Git branch
297+
example: main
298+
token:
299+
type: string
300+
description: Git token
301+
environment:
302+
type: string
303+
description: Environment name
304+
example: default
305+
domain:
306+
type: object
307+
properties:
308+
id:
309+
type: string
310+
format: uuid
311+
description: Domain ID
312+
name:
313+
type: string
314+
description: Domain name
315+
version:
316+
type: string
317+
description: Domain version
318+
lastcommit:
319+
type: string
320+
description: Last respository commit hash
321+
lastupdate:
322+
type: string
323+
description: Last respository commit date
324+
status:
325+
type: string
326+
description: Sync status
327+
enum: [ "Pending", "Synced", "OutSync", "Error" ]
328+
message:
329+
type: string
330+
description: Sync last message
331+
settings:
332+
type: object
333+
properties:
334+
active:
335+
type: boolean
336+
description: Sync handler status
337+
window:
338+
type: string
339+
description: Sync window time (s, m, h)
340+
example: 1m
341+
forceprune:
342+
type: boolean
343+
description: Force delete elements from the API when true
344+
ErrorResponse:
345+
type: object
346+
properties:
347+
error:
348+
type: string

0 commit comments

Comments
 (0)