mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
[docs] include Swagger into app
This commit is contained in:
parent
c828b8cf0b
commit
d96ff6647b
2
Makefile
2
Makefile
@ -51,7 +51,7 @@ docker-dev:
|
||||
|
||||
api-docs:
|
||||
swag fmt -g ./cmd/$(project_name)/main.go \
|
||||
&& swag init -g ./cmd/$(project_name)/main.go -o ./api
|
||||
&& swag init --parseDependency -g ./cmd/$(project_name)/main.go -o ./api
|
||||
|
||||
view-docs:
|
||||
php -S 127.0.0.1:8080 -t ./api
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
],
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "End-user authentication key",
|
||||
"description": "Provides an API for (Android) SMS Gateway",
|
||||
"title": "SMS Gateway - API",
|
||||
"contact": {
|
||||
"name": "Aleksandr Soloshenko",
|
||||
"email": "i@capcom.me"
|
||||
},
|
||||
"version": "1.0.0"
|
||||
"version": "{APP_VERSION}"
|
||||
},
|
||||
"host": "sms.capcom.me",
|
||||
"basePath": "/api",
|
||||
|
||||
@ -273,9 +273,9 @@ info:
|
||||
contact:
|
||||
email: i@capcom.me
|
||||
name: Aleksandr Soloshenko
|
||||
description: End-user authentication key
|
||||
description: Provides an API for (Android) SMS Gateway
|
||||
title: SMS Gateway - API
|
||||
version: 1.0.0
|
||||
version: '{APP_VERSION}'
|
||||
paths:
|
||||
/3rdparty/v1/device:
|
||||
get:
|
||||
|
||||
@ -6,6 +6,9 @@ ARG APP_VERSION=1.0.0
|
||||
ARG APP_RELEASE_ID=1
|
||||
WORKDIR /go/src
|
||||
|
||||
# Install swag
|
||||
RUN go install github.com/swaggo/swag/cmd/swag@latest
|
||||
|
||||
# Copy go.mod and go.sum
|
||||
COPY go.* ./
|
||||
|
||||
@ -15,6 +18,12 @@ RUN go mod download
|
||||
# Copy all the Code and stuff to compile everything
|
||||
COPY . .
|
||||
|
||||
# Replace {APP_VERSION} with the actual version
|
||||
RUN sed -i "s/{APP_VERSION}/${APP_VERSION}/g" ./cmd/${APP}/main.go
|
||||
|
||||
# Generate swagger docs
|
||||
RUN swag init --parseDependency -g ./cmd/${APP}/main.go -o ./api
|
||||
|
||||
# Builds the application as a staticly linked one, to allow it to run on alpine
|
||||
# RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -o app .
|
||||
RUN CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags="-w -s -X github.com/capcom6/${APP}/internal/version.AppVersion=${APP_VERSION} -X github.com/capcom6/${APP}/internal/version.AppRelease=${APP_RELEASE_ID}" -o app ./cmd/${APP}/main.go
|
||||
@ -28,6 +37,7 @@ RUN apk add --no-cache tzdata
|
||||
|
||||
COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh
|
||||
|
||||
COPY --from=build /go/src/api /app/api
|
||||
COPY --from=build /go/src/app /app
|
||||
|
||||
# Exposes port 3000 because our program listens on that port
|
||||
|
||||
@ -4,21 +4,19 @@ import (
|
||||
smsgateway "github.com/capcom6/sms-gateway/internal/sms-gateway"
|
||||
)
|
||||
|
||||
// @title SMS Gateway - API
|
||||
// @version 1.0.0
|
||||
// @description Provides API for (Android) SMS Gateway
|
||||
|
||||
// @contact.name Aleksandr Soloshenko
|
||||
// @contact.email i@capcom.me
|
||||
// @securitydefinitions.basic ApiAuth
|
||||
|
||||
// @securitydefinitions.apikey MobileToken
|
||||
// @in header
|
||||
// @name Authorization
|
||||
// @description Mobile device token
|
||||
|
||||
// @securitydefinitions.basic ApiAuth
|
||||
// @in header
|
||||
// @description End-user authentication key
|
||||
// @title SMS Gateway - API
|
||||
// @version {APP_VERSION}
|
||||
// @description Provides an API for (Android) SMS Gateway
|
||||
|
||||
// @contact.name Aleksandr Soloshenko
|
||||
// @contact.email i@capcom.me
|
||||
|
||||
// @host localhost:3000
|
||||
// @host sms.capcom.me
|
||||
|
||||
@ -10,6 +10,7 @@ type rootHandler struct {
|
||||
|
||||
func (h *rootHandler) Register(app *fiber.App) {
|
||||
h.healthHandler.Register(app)
|
||||
app.Static("/api", "api")
|
||||
}
|
||||
|
||||
func newRootHandler(healthHandler *healthHandler) *rootHandler {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user