Skip to content

Add default API header settings and opendocs #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@
build:
go build -o ./bin/app ./src/cmd/app/main.go

run:
run:test
ifeq ($(OS),Windows_NT)
$env:GO_ENV="test"; go run ./src/cmd/app/main.go
else
GO_ENV=test go run ./src/cmd/app/main.go
endif

run:prod:
ifeq ($(OS),Windows_NT)
$env:GO_ENV="prod"; go run ./src/cmd/app/main.go
else
GO_ENV=prod go run ./src/cmd/app/main.go
endif

test:
go test -p 1 -v ./...
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ You might need to remove mongodb setting from docker-compose.yml if launching th

1. Clone the repository
2. Configure the environment variables in the `.env.test` file
3. `make run` to start the application
3. `make run:test` to start the application

# Integrated tests

Expand Down
348 changes: 348 additions & 0 deletions resources/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,348 @@
openapi: 3.0.1
info:
title: Switcher GitOps
version: v1.0.1
description: GitOps Domain Snapshot Orchestrator for Switcher API.
contact:
name: Roger Floriano (petruki)
email: switcher.project@gmail.com
url: https://github.com/petruki
license:
name: MIT
url: https://github.com/switcherapi/switcher-gitops/blob/master/LICENSE
servers:
- url: http://localhost:8000
description: Local
- url: https://localhost:8000
description: Remote
paths:
/api/check:
get:
tags:
- API
summary: Check API status
description: Check API status
responses:
'200':
description: API status
content:
application/json:
schema:
type: object
properties:
status:
type: string
description: API status
version:
type: string
description: API version
release_time:
type: string
description: API last release date time
api_settings:
type: object
properties:
switcher_url:
type: string
description: Switcher API URL
switcher_secret:
type: boolean
description: Has Switcher API secret
git_token_secret:
type: boolean
description: Has Git token secret
core_handler_status:
type: boolean
description: Core handler status (-1 Created, 0 Initialized, 1 Running)
enum: [ "-1", "0", "1" ]
num_goroutines:
type: integer
description: Number of goroutines running
/account:
post:
tags:
- Account API
summary: Create a new account
description: Create a new account and starts handler when active
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AccountRequest'
responses:
'201':
description: Account created
content:
application/json:
schema:
$ref: '#/components/schemas/AccountResponse'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Error creating accoun
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
put:
tags:
- Account API
summary: Update an existing account
description: Update an existing account and starts handler when active
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AccountRequest'
responses:
'200':
description: Account updated
content:
application/json:
schema:
$ref: '#/components/schemas/AccountResponse'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Error updating account
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/account/{domainId}:
get:
tags:
- Account API
summary: Get All accounts by domain ID
description: Get all accounts by domain ID
parameters:
- name: domainId
in: path
required: true
description: Domain ID
schema:
type: string
format: uuid
responses:
'200':
description: Account list
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/AccountResponse'
'404':
description: Accounts not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Error getting accounts
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/account/{domainId}/{environment}:
get:
tags:
- Account API
summary: Get account by domain ID and environment
description: Get account by domain ID and environment
parameters:
- name: domainId
in: path
required: true
description: Domain ID
schema:
type: string
format: uuid
- name: environment
in: path
required: true
description: Environment name
schema:
type: string
responses:
'200':
description: Account list
content:
application/json:
schema:
$ref: '#/components/schemas/AccountResponse'
'404':
description: Account not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Error getting account
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
delete:
tags:
- Account API
summary: Delete account by domain ID and environment
description: Delete account by domain ID and environment
parameters:
- name: domainId
in: path
required: true
description: Domain ID
schema:
type: string
format: uuid
- name: environment
in: path
required: true
description: Environment name
schema:
type: string
responses:
'204':
description: Account deleted
'400':
description: Invalid request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Error deleting account
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
AccountRequest:
type: object
properties:
repository:
type: string
description: Git repository URL
branch:
type: string
description: Git branch
example: main
token:
type: string
description: Git token
environment:
type: string
description: Environment name
example: default
domain:
type: object
properties:
id:
type: string
format: uuid
description: Domain ID
name:
type: string
description: Domain name
settings:
type: object
properties:
active:
type: boolean
description: Sync handler status
window:
type: string
description: Sync window time (s, m, h)
example: 1m
forceprune:
type: boolean
description: Force delete elements from the API when true
AccountResponse:
type: object
properties:
_id:
type: string
format: uuid
description: Account ID
repository:
type: string
description: Git repository URL
branch:
type: string
description: Git branch
example: main
token:
type: string
description: Git token
environment:
type: string
description: Environment name
example: default
domain:
type: object
properties:
id:
type: string
format: uuid
description: Domain ID
name:
type: string
description: Domain name
version:
type: string
description: Domain version
lastcommit:
type: string
description: Last respository commit hash
lastupdate:
type: string
description: Last respository commit date
status:
type: string
description: Sync status
enum: [ "Pending", "Synced", "OutSync", "Error" ]
message:
type: string
description: Sync last message
settings:
type: object
properties:
active:
type: boolean
description: Sync handler status
window:
type: string
description: Sync window time (s, m, h)
example: 1m
forceprune:
type: boolean
description: Force delete elements from the API when true
ErrorResponse:
type: object
properties:
error:
type: string
Loading