bankserver_rust/openapi-def.yaml

782 lines
20 KiB
YAML

# yaml-language-server: $schema=https://spec.openapis.org/oas/3.1/schema/2024-11-14
openapi: 3.1.0
info:
title: Bankserver
version: 0.0.1
tags:
- name: Authentication
- name: Meta
- name: Users
- name: Accounts
- name: Transactions
- name: Chats
paths:
/api/meta/motd:
get:
operationId: meta-motd
tags:
- Meta
responses:
200:
description: Motd
content:
application/json:
schema:
$ref: '#/components/schemas/Motd'
default:
$ref: '#/components/responses/Default'
/api/meta/bank:
get:
operationId: meta-bank
tags:
- Meta
responses:
200:
description: Bank
content:
application/json:
schema:
$ref: '#/components/schemas/Bank'
default:
$ref: '#/components/responses/Default'
/api/login:
post:
operationId: login
tags:
- Authentication
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Credentials'
responses:
200:
description: Login successful
content:
application/json:
schema:
$ref: '#/components/schemas/TokenResponse'
403:
description: Invalid username or password
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
example:
id: auth.invalid_credentials
message: string
422:
$ref: '#/components/responses/InvalidBody'
default:
$ref: '#/components/responses/Default'
/api/register:
post:
operationId: register
tags:
- Authentication
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Credentials'
responses:
201:
description: Registration successful
content:
application/json:
schema:
$ref: '#/components/schemas/TokenResponse'
409:
description: User already exists
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
example:
id: conflict
message: string
422:
$ref: '#/components/responses/InvalidBody'
default:
$ref: '#/components/responses/Default'
/api/users/{userId}:
get:
operationId: user-info
summary: User Info
parameters:
- $ref: '#/components/parameters/UserId'
tags:
- Users
security:
- bearer: []
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/User'
404:
$ref: '#/components/responses/ResourceNotFound'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/users/@me:
get:
operationId: self-get-info
summary: User Info
tags:
- Users
security:
- bearer: []
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/User'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/users/@me/password:
put:
operationId: self-change-password
summary: Change password
tags:
- Users
security:
- bearer: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ChangePassword'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/TokenResponse'
401:
$ref: '#/components/responses/Unauthorized'
422:
$ref: '#/components/responses/InvalidBody'
default:
$ref: '#/components/responses/Default'
/api/users/@me/data:
get:
operationId: self-list-data
summary: List user data keys
tags:
- Users
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/UserDataKey'
responses:
200:
description: Ok
content:
application/json:
schema:
type: array
items:
type: string
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/users/@me/data/{key}:
get:
operationId: self-get-data
summary: User data
tags:
- Users
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/UserDataKey'
responses:
200:
description: Ok
content:
application/json:
schema: {}
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
put:
operationId: self-set-data
summary: Set User data
tags:
- Users
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/UserDataKey'
requestBody:
content:
application/json:
schema: {}
responses:
200:
description: Ok
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/users/@me/balance:
get:
operationId: self-get-balance
summary: Sum of all account balances
tags:
- Users
security:
- bearer: []
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/UserBalance'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/users/@me/accounts:
get:
operationId: self-list-accounts
summary: User accounts
tags:
- Users
- Accounts
security:
- bearer: []
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/UserAccounts'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/users/@me/transactions:
get:
operationId: self-transaction-history
summary: Transaction history
tags:
- Users
- Transactions
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/Direction'
- $ref: '#/components/parameters/PaginationOffset'
- $ref: '#/components/parameters/PaginationLimit'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedTransactions'
401:
$ref: '#/components/responses/Unauthorized'
400:
$ref: '#/components/responses/BadRequest'
default:
$ref: '#/components/responses/Default'
/api/transactions:
post:
operationId: pay
summary: Make payment
tags:
- Transactions
security:
- bearer: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/MakePayment'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/Transaction'
400:
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
examples:
insufficient_funds:
value:
id: transaction.insufficient_funds
message: string
401:
$ref: '#/components/responses/Unauthorized'
403:
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
404:
description: Targetted or originating account not found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
examples:
from_not_found:
value:
id: transaction.from.not_found
message: string
target_not_found:
value:
id: transaction.target.not_found
message: string
422:
$ref: '#/components/responses/InvalidBody'
default:
$ref: '#/components/responses/Default'
/api/accounts:
get:
operationId: accounts-list-all
summary: List all accounts
tags:
- Accounts
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/PaginationOffset'
- $ref: '#/components/parameters/PaginationLimit'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedAccounts'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/accounts/{accountId}/transactions:
get:
operationId: account-transaction-history
summary: Transaction history
tags:
- Accounts
- Transactions
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/AccountId'
- $ref: '#/components/parameters/Direction'
- $ref: '#/components/parameters/PaginationOffset'
- $ref: '#/components/parameters/PaginationLimit'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedTransactions'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/users:
get:
operationId: users-list-all
summary: List all users
parameters:
- $ref: '#/components/parameters/PaginationOffset'
- $ref: '#/components/parameters/PaginationLimit'
tags:
- Users
security:
- bearer: []
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedUserList'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/users/interop:
get:
operationId: users-list-all-interop
summary: List all remote users
tags:
- Users
security:
- bearer: []
responses:
200:
description: Ok
content:
application/json:
schema:
type: array
items:
type: string
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/chats:
get:
operationId: list-chats
summary: List all chats the user has access to
tags:
- Chats
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/PaginationOffset'
- $ref: '#/components/parameters/PaginationLimit'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedChatInfos'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
post:
operationId: start-chat
summary: Start a new chat
tags:
- Chats
security:
- bearer: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/StartChat'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/Chat'
401:
$ref: '#/components/responses/Unauthorized'
403:
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
404:
$ref: '#/components/responses/ResourceNotFound'
422:
$ref: '#/components/responses/InvalidBody'
default:
$ref: '#/components/responses/Default'
/api/chats/{chatId}:
get:
operationId: chat-info
summary: Info about a chat
tags:
- Chats
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/ChatId'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/ChatInfo'
401:
$ref: '#/components/responses/Unauthorized'
403:
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
404:
$ref: '#/components/responses/ResourceNotFound'
default:
$ref: '#/components/responses/Default'
/api/chats/{chatId}/messages:
get:
operationId: get-chat-messages
summary: List messages in chat
tags:
- Chats
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/ChatId'
- $ref: '#/components/parameters/PaginationOffset'
- $ref: '#/components/parameters/PaginationLimit'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedChatMessages'
401:
$ref: '#/components/responses/Unauthorized'
403:
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
404:
$ref: '#/components/responses/ResourceNotFound'
default:
$ref: '#/components/responses/Default'
post:
operationId: send-chat-message
summary: Send message message into chat
tags:
- Chats
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/ChatId'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SendMessage'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/ChatMessage'
401:
$ref: '#/components/responses/Unauthorized'
403:
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
404:
$ref: '#/components/responses/ResourceNotFound'
422:
$ref: '#/components/responses/InvalidBody'
default:
$ref: '#/components/responses/Default'
/api/chats/{chatId}/messages/{messageId}/read:
post:
operationId: mark-chat-message-read
summary: Mark message as read/unread
tags:
- Chats
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/ChatId'
- $ref: '#/components/parameters/MessageId'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/ChatMessage'
401:
$ref: '#/components/responses/Unauthorized'
403:
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
404:
$ref: '#/components/responses/ResourceNotFound'
422:
$ref: '#/components/responses/InvalidBody'
default:
$ref: '#/components/responses/Default'
/api/socket:
get:
operationId: websocket-events
summary: Open websocket to receive events
security:
- bearer: []
responses:
101:
description: Switching protocols
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
components:
parameters:
Direction:
name: direction
in: query
schema:
$ref: '#/components/schemas/Direction'
required: false
AccountId:
name: accountId
in: path
required: true
schema:
type: string
format: uuid
UserId:
name: userId
in: path
required: true
schema:
type: string
format: uuid
UserDataKey:
name: key
in: path
required: true
schema:
type: string
maxLength: 64
ChatId:
name: chatId
in: path
required: true
schema:
type: string
format: uuid
MessageId:
name: messageId
in: path
required: true
schema:
type: string
format: uuid
PaginationLimit:
name: limit
in: query
required: true
schema:
type: integer
format: uint64
minimum: 0
maximum: 50
PaginationOffset:
name: offset
in: query
schema:
type: integer
format: uint64
minimum: 0
default: 0
securitySchemes:
bearer:
type: http
scheme: bearer
bearerFormat: JWT
examples:
MalformedQuery:
value:
id: malformed_query
message: string
responses:
InternalServerEror:
description: Internal Server Error
Default:
description: Other Errors
InvalidBody:
description: ""
content:
application/json:
schema:
$ref: '#/components/schemas/ValidationError'
Unauthorized:
description: Access token is missing or invalid
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
examples:
missing_header:
value:
id: auth.missing_header
message: string
invalid_jwt:
value:
id: auth.jwt.invalid
message: string
expired_jwt:
value:
id: auth.jwt.expired
message: string
BadRequest:
description: Bad Request
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
examples:
malformed_query:
$ref: '#/components/examples/MalformedQuery'
ResourceNotFound:
description: Resource not found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
example:
id: not_found
message: Not found
UnprocessableEntity:
description: Unprocessable Entity
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
examples:
malformed_body:
value:
id: malformed_body
message: string