MSP-1070 update swagger

This commit is contained in:
DeniskaRediska committed 2022-10-10 16:32:13 +03:00
1 parent e2df3f377d
commit 14d526e033
4 files changed
+196 -71

No files matched your search

+11
View File
@@ -21,6 +21,17 @@ func NewSecure(service SecureService) Secure {
}
}
// Authenticate
// @Tags secure
// @Summary Метод аутентификации токена
// @Description Проверяет токен и возвращает идентификатор администратора
// @Accept json
// @Produce json
// @Param X-AUTH-ADMIN header string true "Токен администратора"
// @Param body body domain.SecureAuthRequest true "Тело запроса"
// @Success 200 {object} domain.SecureAuthResponse
// @Failure 500 {object} domain.GrpcError
// @Router /secure/authenticate [POST]
func (s Secure) Authenticate(ctx context.Context, req domain.SecureAuthRequest) (*domain.SecureAuthResponse, error) {
adminId, err := s.service.GetUserId(ctx, req.Token)
switch {
+109 -40
View File
@@ -39,7 +39,7 @@ var doc = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/domain.AuthRequest"
"$ref": "#/definitions/domain.LoginRequest"
}
}
],
@@ -47,7 +47,7 @@ var doc = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Auth"
"$ref": "#/definitions/domain.LoginResponse"
}
},
"400": {
@@ -91,7 +91,7 @@ var doc = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/domain.SudirAuthRequest"
"$ref": "#/definitions/domain.LoginSudirRequest"
}
}
],
@@ -99,7 +99,7 @@ var doc = `{
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Auth"
"$ref": "#/definitions/domain.LoginResponse"
}
},
"401": {
@@ -164,6 +164,53 @@ var doc = `{
}
}
},
"/secure/authenticate": {
"post": {
"description": "Проверяет токен и возвращает идентификатор администратора",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"secure"
],
"summary": "Метод аутентификации токена",
"parameters": [
{
"type": "string",
"description": "Токен администратора",
"name": "X-AUTH-ADMIN",
"in": "header",
"required": true
},
{
"description": "Тело запроса",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/domain.SecureAuthRequest"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.SecureAuthResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/domain.GrpcError"
}
}
}
}
},
"/user/create_user": {
"post": {
"description": "Создать пользователя",
@@ -521,35 +568,6 @@ var doc = `{
}
}
},
"domain.Auth": {
"type": "object",
"properties": {
"expired": {
"type": "string"
},
"headerName": {
"type": "string"
},
"token": {
"type": "string"
}
}
},
"domain.AuthRequest": {
"type": "object",
"required": [
"email",
"password"
],
"properties": {
"email": {
"type": "string"
},
"password": {
"type": "string"
}
}
},
"domain.CreateUserRequest": {
"type": "object",
"required": [
@@ -613,7 +631,36 @@ var doc = `{
}
}
},
"domain.SudirAuthRequest": {
"domain.LoginRequest": {
"type": "object",
"required": [
"email",
"password"
],
"properties": {
"email": {
"type": "string"
},
"password": {
"type": "string"
}
}
},
"domain.LoginResponse": {
"type": "object",
"properties": {
"expired": {
"type": "string"
},
"headerName": {
"type": "string"
},
"token": {
"type": "string"
}
}
},
"domain.LoginSudirRequest": {
"type": "object",
"required": [
"authCode"
@@ -624,6 +671,28 @@ var doc = `{
}
}
},
"domain.SecureAuthRequest": {
"type": "object",
"properties": {
"token": {
"type": "string"
}
}
},
"domain.SecureAuthResponse": {
"type": "object",
"properties": {
"adminId": {
"type": "integer"
},
"authenticated": {
"type": "boolean"
},
"errorReason": {
"type": "string"
}
}
},
"domain.UpdateUserRequest": {
"type": "object",
"required": [
@@ -653,31 +722,31 @@ var doc = `{
"domain.User": {
"type": "object",
"properties": {
"created_at": {
"createdAt": {
"type": "string"
},
"email": {
"type": "string"
},
"first_name": {
"firstName": {
"type": "string"
},
"id": {
"type": "integer"
},
"last_name": {
"lastName": {
"type": "string"
},
"password": {
"type": "string"
},
"role_id": {
"roleId": {
"type": "integer"
},
"sudir_user_id": {
"sudirUserId": {
"type": "string"
},
"updated_at": {
"updatedAt": {
"type": "string"
}
}
+75 -30
View File
@@ -20,25 +20,6 @@ definitions:
required:
- email
type: object
domain.Auth:
properties:
expired:
type: string
headerName:
type: string
token:
type: string
type: object
domain.AuthRequest:
properties:
email:
type: string
password:
type: string
required:
- email
- password
type: object
domain.CreateUserRequest:
properties:
email:
@@ -80,13 +61,46 @@ definitions:
required:
- ids
type: object
domain.SudirAuthRequest:
domain.LoginRequest:
properties:
email:
type: string
password:
type: string
required:
- email
- password
type: object
domain.LoginResponse:
properties:
expired:
type: string
headerName:
type: string
token:
type: string
type: object
domain.LoginSudirRequest:
properties:
authCode:
type: string
required:
- authCode
type: object
domain.SecureAuthRequest:
properties:
token:
type: string
type: object
domain.SecureAuthResponse:
properties:
adminId:
type: integer
authenticated:
type: boolean
errorReason:
type: string
type: object
domain.UpdateUserRequest:
properties:
email:
@@ -106,23 +120,23 @@ definitions:
type: object
domain.User:
properties:
created_at:
createdAt:
type: string
email:
type: string
first_name:
firstName:
type: string
id:
type: integer
last_name:
lastName:
type: string
password:
type: string
role_id:
roleId:
type: integer
sudir_user_id:
sudirUserId:
type: string
updated_at:
updatedAt:
type: string
type: object
domain.UsersRequest:
@@ -165,14 +179,14 @@ paths:
name: body
required: true
schema:
$ref: '#/definitions/domain.AuthRequest'
$ref: '#/definitions/domain.LoginRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.Auth'
$ref: '#/definitions/domain.LoginResponse'
"400":
description: Bad Request
schema:
@@ -199,14 +213,14 @@ paths:
name: body
required: true
schema:
$ref: '#/definitions/domain.SudirAuthRequest'
$ref: '#/definitions/domain.LoginSudirRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.Auth'
$ref: '#/definitions/domain.LoginResponse'
"401":
description: Некорректный код для авторизации
schema:
@@ -249,6 +263,37 @@ paths:
summary: Выход из авторизованной сессии
tags:
- auth
/secure/authenticate:
post:
consumes:
- application/json
description: Проверяет токен и возвращает идентификатор администратора
parameters:
- description: Токен администратора
in: header
name: X-AUTH-ADMIN
required: true
type: string
- description: Тело запроса
in: body
name: body
required: true
schema:
$ref: '#/definitions/domain.SecureAuthRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/domain.SecureAuthResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/domain.GrpcError'
summary: Метод аутентификации токена
tags:
- secure
/user/create_user:
post:
consumes:
+1 -1
View File
@@ -19,7 +19,7 @@ var version = "1.0.0"
// @host localhost:9000
// @BasePath /api/admin
//go:generate swag init --parseDependency
//go:generate swag init
//go:generate rm -f docs/swagger.json
func main() {