openapi: 3.0.3 info: title: Accounts service API description: API сервиса аккаунтов version: 1.0.0 servers: - url: http://accounts-service:8080 tags: - name: User description: API для управления пользователями - name: TrCash description: API для отражения операций с наличными - name: TrTransfer description: API для отражения денежных переводов paths: /transactions/cash: post: tags: - TrCash operationId: createCashTransaction summary: Создает транзакцию по операции с наличными requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CashTransactionRequest' responses: '204': description: Транзакция выполнена '400': description: Неверный запрос (валидация не пройдена) '409': description: Ошибка при выполнении транзакции content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /transactions/transfer: post: tags: - TrTransfer operationId: createTransferTransaction summary: Создает транзакцию по денежному переводу requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/TransferTransactionRequest' responses: '204': description: Транзакция выполнена '400': description: Неверный запрос (валидация не пройдена) '409': description: Ошибка при выполнении транзакции content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /users: get: tags: - User operationId: listUsers summary: Получить список пользователей responses: 200: description: Полный список пользователей content: application/json: schema: type: array items: $ref: '#/components/schemas/UserShort' post: tags: - User operationId: createUser summary: Регистрирует нового пользователя requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UserCreate' responses: '201': description: Пользователь создан content: application/json: schema: $ref: '#/components/schemas/UserInfo' '400': description: Неверный запрос (валидация не пройдена) '409': description: Такой пользователь уже существует content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /users/{login}: get: tags: - User operationId: getUserAccounts summary: Получить информацию о пользователе и его счетах parameters: - $ref: '#/components/parameters/loginPathParam' responses: 200: description: content: application/json: schema: $ref: '#/components/schemas/UserAccounts' patch: tags: - User operationId: updateUserAccounts summary: Обновление данных пользователя и его счетов parameters: - $ref: '#/components/parameters/loginPathParam' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UserUpdateRequest' responses: '204': description: Данные успешно обновлены '400': description: Неверный запрос (валидация не пройдена) '404': description: Пользователь не найден '409': description: Счет с ненулевым балансом не можеть быть закрыт content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' delete: tags: - User operationId: deleteUser summary: Удаление пользователя parameters: - $ref: '#/components/parameters/loginPathParam' responses: '204': description: Пользователь успешно удален '400': description: Неверный запрос (валидация не пройдена) '404': description: Пользователь не найден '409': description: Нельзя удалить пользователя если имеются счета с ненулевым балансом content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /users/{login}/validate: post: tags: - User operationId: validate summary: Проверяет наличие пользователя с указанным логином и паролем parameters: - $ref: '#/components/parameters/loginPathParam' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ValidateRequest' responses: '200': description: Успешный ответ content: application/json: schema: $ref: '#/components/schemas/UserInfo' '400': description: Неверный запрос (валидация не пройдена) '401': description: Неверные логин или пароль /users/{login}/password: put: tags: - User operationId: changePassword summary: Меняет пароль пользователя parameters: - $ref: '#/components/parameters/loginPathParam' requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/ChangePasswordRequest' responses: '204': description: Пароль изменен '400': description: Неверный запрос (валидация не пройдена) '404': description: Пользователь не найден components: parameters: loginPathParam: name: login in: path required: true schema: type: string minLength: 1 description: Логин пользователя schemas: CashTransactionRequest: type: object properties: login: type: string description: Логин пользователя amount: type: number format: decimal description: Сумма с двумя знаками после запятой (положительная при зачислении на счет, отрицательная при списании со счета) currency: type: string pattern: '^[A-Z]{3}$' example: "USD" description: Валюта (ISO 4217) required: - login - amount - currency TransferTransactionRequest: type: object properties: login: type: string description: Логин пользователя amount: type: number format: decimal description: Сумма с двумя знаками после запятой currency: type: string description: Валюта (ISO 4217) toLogin: type: string description: Логин получателя toAmount: type: number format: decimal description: Сумма получения toCurrency: type: string description: Валюта получения (ISO 4217) required: - login - amount - currency - toLogin - toAmount - toCurrency UserShort: type: object properties: login: type: string name: type: string required: - login - name UserCreate: type: object properties: login: type: string minLength: 1 maxLength: 50 example: "user123" description: Логин пользователя password: type: string minLength: 1 maxLength: 100 format: password example: "qwerty123" description: Пароль (непустой) name: type: string minLength: 1 maxLength: 100 description: Фамилия Имя birthDate: type: string format: date description: Дата рождения required: - login - password - name - birthDate UserInfo: type: object properties: login: type: string description: Логин пользователя name: type: string description: Фамилия Имя birthDate: type: string format: date description: Дата рождения required: - login - name - birthDate UserAccounts: type: object properties: login: type: string description: Логин пользователя name: type: string description: Фамилия Имя birthDate: type: string format: date description: Дата рождения accounts: type: array items: $ref: '#/components/schemas/Account' required: - login - name - birthDate - accounts Account: type: object properties: currency: $ref: '#/components/schemas/Currency' value: type: number format: double example: 1500.75 description: Сумма на счете exists: type: boolean example: true description: Наличие счета у пользователя required: - currency - value - exists Currency: type: object properties: code: type: string example: "USD" description: Код валюты (ISO 4217) name: type: string example: "Доллар США" description: Название валюты required: - code - name UserUpdateRequest: type: object properties: name: type: string nullable: true default: null description: Новое имя пользователя (null - не изменять) birthDate: type: string format: date nullable: true default: null example: "1990-01-20" description: Новая дата рождения (null - не изменять) currencies: type: array items: type: string example: "USD" description: | Список кодов валют для счетов: - [] - закрыть все счета - ["USD", "EUR"] - оставить/добавить счета в этих валютах, закрыть остальные required: - currencies ValidateRequest: type: object properties: password: type: string minLength: 1 description: Пароль required: - password ChangePasswordRequest: type: object properties: password: type: string minLength: 1 maxLength: 100 format: password example: "qwerty123" description: Пароль (непустой) required: - password ErrorResponse: type: object properties: error_code: type: integer format: int32 error_message: type: string required: - error_code - error_message