bankserver_rust/openapi-def.yaml
2025-03-01 18:50:14 +01:00

303 lines
7.5 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: Users
- name: Accounts
- name: Transactions
paths:
/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/LoginSuccess'
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/RegisterSuccess'
409:
description: User already exists
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
example:
id: conflict
message: string
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/UserInfo'
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/UserInfo'
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'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/TransactionHistory'
401:
$ref: '#/components/responses/Unauthorized'
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'
401:
$ref: '#/components/responses/Unauthorized'
403:
description: Forbidden
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
default:
$ref: '#/components/responses/Default'
/api/accounts:
get:
operationId: accounts-list-all
summary: List all accounts
tags:
- Accounts
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/ListAccounts'
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'
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/TransactionHistory'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/users:
get:
operationId: users-list-all
summary: List all users
tags:
- Users
responses:
200:
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/ListUsers'
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
securitySchemes:
bearer:
type: http
scheme: bearer
bearerFormat: JWT
responses:
InternalServerEror:
description: Internal Server Error
Default:
description: Other Errors
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
UnprocessableEntity:
description: Unprocessable Entity
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
examples:
malformed_body:
value:
id: malformed_body
message: string