chore: wip
All checks were successful
Format and Lint / format-check (push) Successful in 14m34s

This commit is contained in:
Максим Слипенко 2024-12-17 19:28:37 +03:00
parent 33e51735cf
commit db49ea2c51
9 changed files with 68 additions and 19 deletions

View file

@ -5,7 +5,7 @@ WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN make build
RUN make release
FROM registry.altlinux.org/sisyphus/alt:20241211

View file

@ -23,7 +23,12 @@ build:
-o aides-repo-api \
./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:
docker build -t ghcr.io/aides-infra/aides-repo-api .
.PHONY: format swag

View file

@ -4,6 +4,17 @@ import (
"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() {
app, err := app.New()
if err != nil {

View file

@ -10,6 +10,10 @@ const docTemplate = `{
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"license": {
"name": "GPL-3.0",
"url": "https://www.gnu.org/licenses/gpl-3.0-standalone.html"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
@ -25,7 +29,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"Tasks"
"tasks"
],
"summary": "Create a new task",
"parameters": [
@ -71,7 +75,7 @@ const docTemplate = `{
"application/json"
],
"tags": [
"Tasks"
"tasks"
],
"summary": "Upload files to a task",
"parameters": [
@ -185,7 +189,13 @@ const docTemplate = `{
}
}
}
}
},
"tags": [
{
"description": "Work with tags",
"name": "tasks"
}
]
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
@ -193,9 +203,9 @@ var SwaggerInfo = &swag.Spec{
Version: "",
Host: "",
BasePath: "",
Schemes: []string{},
Title: "",
Description: "",
Schemes: []string{"https"},
Title: "Aides Repo API",
Description: "API For Aides repo",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",

View file

@ -1,7 +1,16 @@
{
"schemes": [
"https"
],
"swagger": "2.0",
"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": {
"/tasks": {
@ -14,7 +23,7 @@
"application/json"
],
"tags": [
"Tasks"
"tasks"
],
"summary": "Create a new task",
"parameters": [
@ -60,7 +69,7 @@
"application/json"
],
"tags": [
"Tasks"
"tasks"
],
"summary": "Upload files to a task",
"parameters": [
@ -174,5 +183,11 @@
}
}
}
}
},
"tags": [
{
"description": "Work with tags",
"name": "tasks"
}
]
}

View file

@ -52,6 +52,11 @@ definitions:
type: object
info:
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:
/tasks:
post:
@ -82,7 +87,7 @@ paths:
$ref: '#/definitions/errors.ErrResponse'
summary: Create a new task
tags:
- Tasks
- tasks
/tasks/{taskID}/upload:
post:
consumes:
@ -117,5 +122,10 @@ paths:
$ref: '#/definitions/errors.ErrResponse'
summary: Upload files to a task
tags:
- Tasks
- tasks
schemes:
- https
swagger: "2.0"
tags:
- description: Work with tags
name: tasks

View file

@ -27,7 +27,7 @@ func (c *CreateTaskResponse) Render(w http.ResponseWriter, r *http.Request) erro
//
// @Summary Create a new task
// @Description Create a new task for a specific repository
// @Tags Tasks
// @Tags tasks
// @Accept json
// @Produce json
// @Param body body CreateTaskDTO true "Request body to create a task"

View file

@ -24,7 +24,7 @@ func (rd *TaskUploadResponse) Render(w http.ResponseWriter, r *http.Request) err
//
// @Summary Upload files to a task
// @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
// @Produce json
// @Param taskID path string true "Task ID"

View file

@ -33,10 +33,8 @@ func (r *Router) Setup() *chi.Mux {
router := chi.NewRouter()
router.Use(logger)
docs.SwaggerInfo.Title = "Aides Repo API"
docs.SwaggerInfo.Version = config.Version
docs.SwaggerInfo.BasePath = "/"
docs.SwaggerInfo.Schemes = []string{"https"}
router.Get("/swagger/*", httpSwagger.WrapHandler)
router.Route("/tasks", func(taskRouter chi.Router) {