fix openapi specification

This commit is contained in:
DSeeLP 2025-03-18 16:40:09 +01:00
parent 02b56c745d
commit dd163f4ec5
2 changed files with 74 additions and 7 deletions

View File

@ -22,7 +22,7 @@ impl<'a> axum::response::IntoResponse for ApiError<'a> {
impl<'a> ApiError<'a> {
pub const NOT_FOUND: ApiError<'static> =
ApiError::const_new(StatusCode::NOT_FOUND, "not-found", "Not found");
ApiError::const_new(StatusCode::NOT_FOUND, "not_found", "Not found");
pub const INTERNAL_SERVER_ERROR: ApiError<'static> = ApiError::const_new(
StatusCode::INTERNAL_SERVER_ERROR,
"internal-server-error",

View File

@ -161,6 +161,8 @@ paths:
$ref: '#/components/schemas/PaginatedTransactions'
401:
$ref: '#/components/responses/Unauthorized'
400:
$ref: '#/components/responses/BadRequest'
default:
$ref: '#/components/responses/Default'
/api/transactions:
@ -183,6 +185,17 @@ paths:
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:
@ -191,6 +204,21 @@ paths:
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:
@ -203,6 +231,9 @@ paths:
- Accounts
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/PaginationOffset'
- $ref: '#/components/parameters/PaginationLimit'
responses:
200:
description: Ok
@ -210,6 +241,10 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/PaginatedAccounts'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
@ -234,6 +269,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/PaginatedTransactions'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
default:
@ -256,6 +293,10 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/PaginatedUserList'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
default:
$ref: '#/components/responses/Default'
/api/chats:
@ -266,6 +307,9 @@ paths:
- Chats
security:
- bearer: []
parameters:
- $ref: '#/components/parameters/PaginationOffset'
- $ref: '#/components/parameters/PaginationLimit'
responses:
200:
description: Ok
@ -273,6 +317,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/PaginatedChatInfos'
400:
$ref: '#/components/responses/BadRequest'
401:
$ref: '#/components/responses/Unauthorized'
403:
@ -293,7 +339,8 @@ paths:
requestBody:
content:
application/json:
$ref: '#/components/schemas/StartChat'
schema:
$ref: '#/components/schemas/StartChat'
responses:
200:
description: Ok
@ -383,7 +430,8 @@ paths:
requestBody:
content:
application/json:
$ref: '#/components/schemas/SendMessage'
schema:
$ref: '#/components/schemas/SendMessage'
responses:
200:
description: Ok
@ -452,18 +500,28 @@ components:
in: query
required: true
schema:
type: uint64
type: integer
format: uint64
minimum: 0
maximum: 50
PaginationOffset:
name: offset
in: query
default: 0
schema:
type: uint64
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
@ -490,6 +548,15 @@ components:
value:
id: auth.jwt.invalid
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:
@ -497,7 +564,7 @@ components:
schema:
$ref: '#/components/schemas/ApiError'
example:
id: not-found
id: not_found
message: Not found
UnprocessableEntity:
description: Unprocessable Entity