This commit is contained in:
parent
33e51735cf
commit
db49ea2c51
9 changed files with 68 additions and 19 deletions
|
@ -5,7 +5,7 @@ WORKDIR /app
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN make build
|
RUN make release
|
||||||
|
|
||||||
FROM registry.altlinux.org/sisyphus/alt:20241211
|
FROM registry.altlinux.org/sisyphus/alt:20241211
|
||||||
|
|
||||||
|
|
7
Makefile
7
Makefile
|
@ -23,7 +23,12 @@ build:
|
||||||
-o aides-repo-api \
|
-o aides-repo-api \
|
||||||
./cmd/aides-repo-api/main.go
|
./cmd/aides-repo-api/main.go
|
||||||
|
|
||||||
|
release:
|
||||||
|
go build \
|
||||||
|
-ldflags="-s -w -X 'code.alt-gnome.ru/aides-infra/aides-repo-api/internal/config.Version=$(GIT_VERSION)'" \
|
||||||
|
-o aides-repo-api \
|
||||||
|
./cmd/aides-repo-api/main.go
|
||||||
|
|
||||||
build-docker:
|
build-docker:
|
||||||
docker build -t ghcr.io/aides-infra/aides-repo-api .
|
docker build -t ghcr.io/aides-infra/aides-repo-api .
|
||||||
|
|
||||||
.PHONY: format swag
|
|
||||||
|
|
|
@ -4,6 +4,17 @@ import (
|
||||||
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/app"
|
"code.alt-gnome.ru/aides-infra/aides-repo-api/internal/app"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// _
|
||||||
|
//
|
||||||
|
// @title Aides Repo API
|
||||||
|
// @description API For Aides repo
|
||||||
|
// @schemes https
|
||||||
|
//
|
||||||
|
// @license.name GPL-3.0
|
||||||
|
// @license.url https://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
//
|
||||||
|
// @tag.name tasks
|
||||||
|
// @tag.description Work with tags
|
||||||
func main() {
|
func main() {
|
||||||
app, err := app.New()
|
app, err := app.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
20
docs/docs.go
20
docs/docs.go
|
@ -10,6 +10,10 @@ const docTemplate = `{
|
||||||
"description": "{{escape .Description}}",
|
"description": "{{escape .Description}}",
|
||||||
"title": "{{.Title}}",
|
"title": "{{.Title}}",
|
||||||
"contact": {},
|
"contact": {},
|
||||||
|
"license": {
|
||||||
|
"name": "GPL-3.0",
|
||||||
|
"url": "https://www.gnu.org/licenses/gpl-3.0-standalone.html"
|
||||||
|
},
|
||||||
"version": "{{.Version}}"
|
"version": "{{.Version}}"
|
||||||
},
|
},
|
||||||
"host": "{{.Host}}",
|
"host": "{{.Host}}",
|
||||||
|
@ -25,7 +29,7 @@ const docTemplate = `{
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Tasks"
|
"tasks"
|
||||||
],
|
],
|
||||||
"summary": "Create a new task",
|
"summary": "Create a new task",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
@ -71,7 +75,7 @@ const docTemplate = `{
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Tasks"
|
"tasks"
|
||||||
],
|
],
|
||||||
"summary": "Upload files to a task",
|
"summary": "Upload files to a task",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
@ -185,7 +189,13 @@ const docTemplate = `{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"description": "Work with tags",
|
||||||
|
"name": "tasks"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}`
|
}`
|
||||||
|
|
||||||
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
// SwaggerInfo holds exported Swagger Info so clients can modify it
|
||||||
|
@ -193,9 +203,9 @@ var SwaggerInfo = &swag.Spec{
|
||||||
Version: "",
|
Version: "",
|
||||||
Host: "",
|
Host: "",
|
||||||
BasePath: "",
|
BasePath: "",
|
||||||
Schemes: []string{},
|
Schemes: []string{"https"},
|
||||||
Title: "",
|
Title: "Aides Repo API",
|
||||||
Description: "",
|
Description: "API For Aides repo",
|
||||||
InfoInstanceName: "swagger",
|
InfoInstanceName: "swagger",
|
||||||
SwaggerTemplate: docTemplate,
|
SwaggerTemplate: docTemplate,
|
||||||
LeftDelim: "{{",
|
LeftDelim: "{{",
|
||||||
|
|
|
@ -1,7 +1,16 @@
|
||||||
{
|
{
|
||||||
|
"schemes": [
|
||||||
|
"https"
|
||||||
|
],
|
||||||
"swagger": "2.0",
|
"swagger": "2.0",
|
||||||
"info": {
|
"info": {
|
||||||
"contact": {}
|
"description": "API For Aides repo",
|
||||||
|
"title": "Aides Repo API",
|
||||||
|
"contact": {},
|
||||||
|
"license": {
|
||||||
|
"name": "GPL-3.0",
|
||||||
|
"url": "https://www.gnu.org/licenses/gpl-3.0-standalone.html"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"paths": {
|
"paths": {
|
||||||
"/tasks": {
|
"/tasks": {
|
||||||
|
@ -14,7 +23,7 @@
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Tasks"
|
"tasks"
|
||||||
],
|
],
|
||||||
"summary": "Create a new task",
|
"summary": "Create a new task",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
@ -60,7 +69,7 @@
|
||||||
"application/json"
|
"application/json"
|
||||||
],
|
],
|
||||||
"tags": [
|
"tags": [
|
||||||
"Tasks"
|
"tasks"
|
||||||
],
|
],
|
||||||
"summary": "Upload files to a task",
|
"summary": "Upload files to a task",
|
||||||
"parameters": [
|
"parameters": [
|
||||||
|
@ -174,5 +183,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"tags": [
|
||||||
|
{
|
||||||
|
"description": "Work with tags",
|
||||||
|
"name": "tasks"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
|
@ -52,6 +52,11 @@ definitions:
|
||||||
type: object
|
type: object
|
||||||
info:
|
info:
|
||||||
contact: {}
|
contact: {}
|
||||||
|
description: API For Aides repo
|
||||||
|
license:
|
||||||
|
name: GPL-3.0
|
||||||
|
url: https://www.gnu.org/licenses/gpl-3.0-standalone.html
|
||||||
|
title: Aides Repo API
|
||||||
paths:
|
paths:
|
||||||
/tasks:
|
/tasks:
|
||||||
post:
|
post:
|
||||||
|
@ -82,7 +87,7 @@ paths:
|
||||||
$ref: '#/definitions/errors.ErrResponse'
|
$ref: '#/definitions/errors.ErrResponse'
|
||||||
summary: Create a new task
|
summary: Create a new task
|
||||||
tags:
|
tags:
|
||||||
- Tasks
|
- tasks
|
||||||
/tasks/{taskID}/upload:
|
/tasks/{taskID}/upload:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
|
@ -117,5 +122,10 @@ paths:
|
||||||
$ref: '#/definitions/errors.ErrResponse'
|
$ref: '#/definitions/errors.ErrResponse'
|
||||||
summary: Upload files to a task
|
summary: Upload files to a task
|
||||||
tags:
|
tags:
|
||||||
- Tasks
|
- tasks
|
||||||
|
schemes:
|
||||||
|
- https
|
||||||
swagger: "2.0"
|
swagger: "2.0"
|
||||||
|
tags:
|
||||||
|
- description: Work with tags
|
||||||
|
name: tasks
|
||||||
|
|
|
@ -27,7 +27,7 @@ func (c *CreateTaskResponse) Render(w http.ResponseWriter, r *http.Request) erro
|
||||||
//
|
//
|
||||||
// @Summary Create a new task
|
// @Summary Create a new task
|
||||||
// @Description Create a new task for a specific repository
|
// @Description Create a new task for a specific repository
|
||||||
// @Tags Tasks
|
// @Tags tasks
|
||||||
// @Accept json
|
// @Accept json
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param body body CreateTaskDTO true "Request body to create a task"
|
// @Param body body CreateTaskDTO true "Request body to create a task"
|
||||||
|
|
|
@ -24,7 +24,7 @@ func (rd *TaskUploadResponse) Render(w http.ResponseWriter, r *http.Request) err
|
||||||
//
|
//
|
||||||
// @Summary Upload files to a task
|
// @Summary Upload files to a task
|
||||||
// @Description Upload multiple files associated with a specific task ID. Each file must be less than 10MB.
|
// @Description Upload multiple files associated with a specific task ID. Each file must be less than 10MB.
|
||||||
// @Tags Tasks
|
// @Tags tasks
|
||||||
// @Accept multipart/form-data
|
// @Accept multipart/form-data
|
||||||
// @Produce json
|
// @Produce json
|
||||||
// @Param taskID path string true "Task ID"
|
// @Param taskID path string true "Task ID"
|
||||||
|
|
|
@ -33,10 +33,8 @@ func (r *Router) Setup() *chi.Mux {
|
||||||
router := chi.NewRouter()
|
router := chi.NewRouter()
|
||||||
router.Use(logger)
|
router.Use(logger)
|
||||||
|
|
||||||
docs.SwaggerInfo.Title = "Aides Repo API"
|
|
||||||
docs.SwaggerInfo.Version = config.Version
|
docs.SwaggerInfo.Version = config.Version
|
||||||
docs.SwaggerInfo.BasePath = "/"
|
|
||||||
docs.SwaggerInfo.Schemes = []string{"https"}
|
|
||||||
router.Get("/swagger/*", httpSwagger.WrapHandler)
|
router.Get("/swagger/*", httpSwagger.WrapHandler)
|
||||||
|
|
||||||
router.Route("/tasks", func(taskRouter chi.Router) {
|
router.Route("/tasks", func(taskRouter chi.Router) {
|
||||||
|
|
Loading…
Reference in a new issue