diff --git a/Dockerfile b/Dockerfile index 55e3326..fb39e3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/Makefile b/Makefile index e868ea3..c58d73b 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/cmd/aides-repo-api/main.go b/cmd/aides-repo-api/main.go index d3bd61c..411a2b1 100644 --- a/cmd/aides-repo-api/main.go +++ b/cmd/aides-repo-api/main.go @@ -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 { diff --git a/docs/docs.go b/docs/docs.go index 843fefa..8b0bbb7 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -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: "{{", diff --git a/docs/swagger.json b/docs/swagger.json index 7804bcf..7c89391 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -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" + } + ] } \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 41f36c8..77ebdd3 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -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 diff --git a/internal/controllers/taskcontroller/create.go b/internal/controllers/taskcontroller/create.go index d70a181..baad0b8 100644 --- a/internal/controllers/taskcontroller/create.go +++ b/internal/controllers/taskcontroller/create.go @@ -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" diff --git a/internal/controllers/taskcontroller/upload.go b/internal/controllers/taskcontroller/upload.go index 335a7d8..7d4c2eb 100644 --- a/internal/controllers/taskcontroller/upload.go +++ b/internal/controllers/taskcontroller/upload.go @@ -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" diff --git a/internal/router/router.go b/internal/router/router.go index 81f8567..e76b15c 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -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) {