-
Notifications
You must be signed in to change notification settings - Fork 0
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
Or 1101 titond backend add swagger and ci for checking if the swagger doc is updated #10
Merged
nguyenzung
merged 13 commits into
main
from
OR-1101-titond-backend-add-swagger-and-ci-for-checking-if-the-swagger-doc-is-updated
Nov 29, 2023
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
b0dcdf2
OR-1101 setup swagger
nguyenzung c9fd307
OR-1101 update swagger config
nguyenzung a056c4e
OR-1101 add checking docs
nguyenzung 0d6fbca
Check swagger docs
nguyenzung a4cb705
OR-1101 update job name
nguyenzung 4707570
OR-1101 update action file for checking swagger
nguyenzung 1542478
OR-1101 update swagger description
nguyenzung ea47483
OR-1101 fix counting method for swagger docs
nguyenzung e8d7b7a
OR-1101 update source code structure
nguyenzung 81c7109
OR-1101 update swagger docs folder
nguyenzung abf3a3f
OR-1101 update Dockerfile
nguyenzung c378486
OR-1101 update docker base image for aws and .gitignore
nguyenzung f204e8b
OR-1101 update dockerfile for aws-cli
nguyenzung File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Check swagger | ||
on: push | ||
|
||
jobs: | ||
image: | ||
name: Check swagger docs for titond-backend | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check swagger | ||
run: | | ||
go run ./cmd/titond/main.go check-swagger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ go.work | |
# Build file | ||
/build | ||
client.http | ||
.env | ||
.env* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
FROM --platform=$BUILDPLATFORM golang:1.20-alpine AS builder | ||
|
||
RUN apk add --no-cache make gcc musl-dev linux-headers git | ||
RUN apk add --no-cache make gcc musl-dev linux-headers git curl | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN go install github.com/swaggo/swag/cmd/swag@latest | ||
|
||
ARG TARGETOS TARGETARCH | ||
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make titond | ||
|
||
FROM alpine | ||
FROM alpine:3.18.4 | ||
RUN apk add --no-cache aws-cli ca-certificates jq | ||
|
||
RUN apk add --no-cache ca-certificates jq curl | ||
COPY --from=builder /app/api /root/api | ||
COPY --from=builder /app/deployments /root/deployments | ||
COPY --from=builder /app/build/bin/titond /usr/local/bin/ | ||
|
||
WORKDIR /usr/local/bin/ | ||
WORKDIR /root | ||
ENTRYPOINT ["titond"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,283 @@ | ||
// Package api Code generated by swaggo/swag. DO NOT EDIT | ||
package api | ||
|
||
import "github.com/swaggo/swag" | ||
|
||
const docTemplate = `{ | ||
"schemes": {{ marshal .Schemes }}, | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "{{escape .Description}}", | ||
"title": "{{.Title}}", | ||
"contact": {}, | ||
"version": "{{.Version}}" | ||
}, | ||
"host": "{{.Host}}", | ||
"basePath": "{{.BasePath}}", | ||
"paths": { | ||
"/api/components": { | ||
"get": { | ||
"description": "Get Component By Type", | ||
"summary": "GetComponentByType", | ||
"operationId": "get-component-by-type", | ||
"parameters": [ | ||
{ | ||
"type": "string", | ||
"description": "Component type (e.g., l2geth)", | ||
"name": "type", | ||
"in": "query", | ||
"required": true | ||
}, | ||
{ | ||
"type": "integer", | ||
"description": "Network ID", | ||
"name": "network_id", | ||
"in": "query", | ||
"required": true | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"type": "object" | ||
} | ||
}, | ||
"400": { | ||
"description": "Bad Request" | ||
}, | ||
"500": { | ||
"description": "Internal Server Error" | ||
} | ||
} | ||
}, | ||
"post": { | ||
"description": "Create a new component", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "CreateComponent", | ||
"operationId": "create-component", | ||
"parameters": [ | ||
{ | ||
"description": "Component data to create", | ||
"name": "input", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"type": "object" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/model.Component" | ||
} | ||
}, | ||
"400": { | ||
"description": "Bad Request" | ||
}, | ||
"500": { | ||
"description": "Internal Server Error" | ||
} | ||
} | ||
} | ||
}, | ||
"/api/components/{id}": { | ||
"get": { | ||
"description": "Get Component By ID", | ||
"summary": "GetComponentByID", | ||
"operationId": "get-component-by-id", | ||
"parameters": [ | ||
{ | ||
"type": "integer", | ||
"description": "Component ID", | ||
"name": "id", | ||
"in": "path", | ||
"required": true | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"type": "object" | ||
} | ||
}, | ||
"400": { | ||
"description": "Bad Request" | ||
}, | ||
"500": { | ||
"description": "Internal Server Error" | ||
} | ||
} | ||
}, | ||
"delete": { | ||
"description": "Delete Component By Id", | ||
"summary": "DeleteComponentById", | ||
"operationId": "delete-component-by-id", | ||
"parameters": [ | ||
{ | ||
"type": "integer", | ||
"description": "Component ID", | ||
"name": "id", | ||
"in": "path", | ||
"required": true | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"type": "object" | ||
} | ||
}, | ||
"400": { | ||
"description": "Bad Request" | ||
}, | ||
"500": { | ||
"description": "Internal Server Error" | ||
} | ||
} | ||
} | ||
}, | ||
"/api/networks": { | ||
"post": { | ||
"description": "Create a new network", | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "CreateNetwork", | ||
"operationId": "create-network", | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/model.Network" | ||
} | ||
}, | ||
"500": { | ||
"description": "Internal Server Error" | ||
} | ||
} | ||
} | ||
}, | ||
"/api/networks/{id}": { | ||
"delete": { | ||
"description": "Delete a network by id", | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "DeleteNetwork", | ||
"operationId": "delete-network", | ||
"parameters": [ | ||
{ | ||
"type": "integer", | ||
"description": "Network ID", | ||
"name": "id", | ||
"in": "path", | ||
"required": true | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"type": "object" | ||
} | ||
}, | ||
"400": { | ||
"description": "Bad Request" | ||
}, | ||
"404": { | ||
"description": "Not Found" | ||
}, | ||
"500": { | ||
"description": "Internal Server Error" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"model.Component": { | ||
"type": "object", | ||
"required": [ | ||
"network_id", | ||
"type" | ||
], | ||
"properties": { | ||
"created_at": { | ||
"type": "integer" | ||
}, | ||
"id": { | ||
"type": "integer" | ||
}, | ||
"name": { | ||
"type": "string" | ||
}, | ||
"network_id": { | ||
"type": "integer" | ||
}, | ||
"public_url": { | ||
"type": "string" | ||
}, | ||
"status": { | ||
"type": "boolean" | ||
}, | ||
"type": { | ||
"type": "string" | ||
}, | ||
"updated_at": { | ||
"type": "integer" | ||
} | ||
} | ||
}, | ||
"model.Network": { | ||
"type": "object", | ||
"properties": { | ||
"contract_address_url": { | ||
"type": "string" | ||
}, | ||
"created_at": { | ||
"type": "integer" | ||
}, | ||
"id": { | ||
"type": "integer" | ||
}, | ||
"state_dump_url": { | ||
"type": "string" | ||
}, | ||
"status": { | ||
"type": "boolean" | ||
}, | ||
"updated_at": { | ||
"type": "integer" | ||
} | ||
} | ||
} | ||
} | ||
}` | ||
|
||
// SwaggerInfo holds exported Swagger Info so clients can modify it | ||
var SwaggerInfo = &swag.Spec{ | ||
Version: "1.0", | ||
Host: "localhost:8080", | ||
BasePath: "", | ||
Schemes: []string{}, | ||
Title: "Titond", | ||
Description: "Titond-backend application", | ||
InfoInstanceName: "swagger", | ||
SwaggerTemplate: docTemplate, | ||
LeftDelim: "{{", | ||
RightDelim: "}}", | ||
} | ||
|
||
func init() { | ||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ohbyeongmin We can use the ./deployments path in container env now!