-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from tokamak-network/OR-1101-titond-backend-ad…
…d-swagger-and-ci-for-checking-if-the-swagger-doc-is-updated Or 1101 titond backend add swagger and ci for checking if the swagger doc is updated
- Loading branch information
Showing
13 changed files
with
971 additions
and
32 deletions.
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.