From 16a3779df5e77d593c885a93ec4a68a87a7674b2 Mon Sep 17 00:00:00 2001 From: Pavel Date: Tue, 23 Apr 2024 14:18:45 +0300 Subject: [PATCH] update openapi --- internal/controllers/user.go | 10 +--- openapi.yaml | 110 ++++++++++++++++++++++++++++------- 2 files changed, 92 insertions(+), 28 deletions(-) diff --git a/internal/controllers/user.go b/internal/controllers/user.go index 91709fd..ada2612 100644 --- a/internal/controllers/user.go +++ b/internal/controllers/user.go @@ -1,8 +1,6 @@ package controllers import ( - "amocrm/internal/repository" - "errors" "github.com/gofiber/fiber/v2" "go.uber.org/zap" "penahub.gitlab.yandexcloud.net/backend/quiz/core.git/middleware" @@ -65,12 +63,8 @@ func (c *Controller) GetCurrentAccount(ctx *fiber.Ctx) error { response, err := c.service.GetCurrentAccount(ctx.Context(), accountID) if err != nil { - switch { - case errors.Is(err, repository.ErrUserNotFound): - return ctx.Status(fiber.StatusNotFound).SendString("User not found") - default: - return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error") - } + return ctx.Status(fiber.StatusInternalServerError).SendString("Internal Server Error") + } return ctx.Status(fiber.StatusOK).JSON(response) } diff --git a/openapi.yaml b/openapi.yaml index a0d491a..ac60d50 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -53,8 +53,6 @@ paths: $ref: '#/components/schemas/GetCurrentAccountResp' '401': $ref: '#/components/responses/401' - '404': - $ref: '#/components/responses/404' '500': $ref: '#/components/responses/500' /webhook/create: @@ -108,15 +106,15 @@ paths: - size responses: '200': - description: успешное получение списка пользователей + description: успешное получение заданных юзером utm меток content: 'application/json': schema: $ref: '#/components/schemas/GetListUserUTMResp' '401': $ref: '#/components/responses/401' - '404': - $ref: '#/components/responses/404' + '400': + $ref: '#/components/responses/400' '500': $ref: '#/components/responses/500' post: @@ -145,8 +143,8 @@ paths: $ref: '#/components/schemas/ListSavedIDUTMResp' '401': $ref: '#/components/responses/401' - '404': - $ref: '#/components/responses/404' + '400': + $ref: '#/components/responses/400' '500': $ref: '#/components/responses/500' delete: @@ -168,11 +166,9 @@ paths: $ref: '#/components/schemas/ListDeleteUTMIDsReq' responses: '200': - description: Success - '401': - $ref: '#/components/responses/401' - '404': - $ref: '#/components/responses/404' + $ref: '#/components/responses/200' + '400': + $ref: '#/components/responses/400' '500': $ref: '#/components/responses/500' /users: @@ -207,6 +203,10 @@ paths: 'application/json': schema: $ref: "#/components/schemas/UserListResp" + '401': + $ref: '#/components/responses/401' + '500': + $ref: '#/components/responses/500' patch: operationId: UpdateListUsers description: обновление списка юзеров @@ -214,7 +214,11 @@ paths: - main responses: '200': - description: Success + $ref: '#/components/responses/200' + '401': + $ref: '#/components/responses/401' + '500': + $ref: '#/components/responses/500' /pipelines: get: operationId: GettingPipelinesFromCash @@ -247,6 +251,10 @@ paths: 'application/json': schema: $ref: "#/components/schemas/UserListPipelinesResp" + '401': + $ref: '#/components/responses/401' + '500': + $ref: '#/components/responses/500' patch: operationId: UpdateListPipelines description: обновление списка воронок @@ -254,7 +262,11 @@ paths: - main responses: '200': - description: Success + $ref: '#/components/responses/200' + '401': + $ref: '#/components/responses/401' + '500': + $ref: '#/components/responses/500' /steps: get: operationId: GettingStepsFromCash @@ -287,6 +299,10 @@ paths: 'application/json': schema: $ref: "#/components/schemas/UserListStepsResp" + '401': + $ref: '#/components/responses/401' + '500': + $ref: '#/components/responses/500' patch: operationId: UpdateListSteps description: обновление списка этапов воронок @@ -294,7 +310,11 @@ paths: - main responses: '200': - description: Success + $ref: '#/components/responses/200' + '401': + $ref: '#/components/responses/401' + '500': + $ref: '#/components/responses/500' /fields: get: operationId: GettingFieldsFromCash @@ -327,6 +347,10 @@ paths: 'application/json': schema: $ref: "#/components/schemas/UserListFieldsResp" + '401': + $ref: '#/components/responses/401' + '500': + $ref: '#/components/responses/500' patch: operationId: UpdateListCustom description: обновление списка кастомных полей @@ -334,7 +358,11 @@ paths: - main responses: '200': - description: Success + $ref: '#/components/responses/200' + '401': + $ref: '#/components/responses/401' + '500': + $ref: '#/components/responses/500' /tags: get: operationId: GettingTagsFromCash @@ -367,6 +395,10 @@ paths: 'application/json': schema: $ref: "#/components/schemas/UserListTagsResp" + '401': + $ref: '#/components/responses/401' + '500': + $ref: '#/components/responses/500' patch: operationId: UpdateListTags description: обновление списка тегов @@ -374,7 +406,11 @@ paths: - main responses: '200': - description: Success + $ref: '#/components/responses/200' + '401': + $ref: '#/components/responses/401' + '500': + $ref: '#/components/responses/500' # таких запросах для блупринта обязательно нужно указывать параметры /rules/{quizID}: get: @@ -818,9 +854,43 @@ components: RulesReq: type: object properties: - ID: - type: string - description: ID квиза + PerformerID: + type: integer + description: "айдишник ответственного за сделку" + PipelineID: + type: integer + description: "айдишник воронки" + StepID: + type: integer + description: "айдишник этапа" + Utms: + type: array + items: + type: integer + description: "список UTM для этого опроса" + Fieldsrule: + type: object + properties: + Lead: + type: array + items: + $ref: "#/components/schemas/FieldRule" + description: "правила заполнения полей сущностей в амо" + Contact: + type: array + items: + $ref: "#/components/schemas/FieldRule" + description: "правила заполнения полей сущностей в амо" + Company: + type: array + items: + $ref: "#/components/schemas/FieldRule" + description: "правила заполнения полей сущностей в амо" + Customer: + type: array + items: + $ref: "#/components/schemas/FieldRule" + description: "правила заполнения полей сущностей в амо" responses: '200':