Last active
January 19, 2025 14:45
-
-
Save indrasaputra/bd45184f4db0f94ba49d9b13015cf794 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swagger: "2.0" | |
info: | |
title: Auth API | |
version: 1.0.0 | |
contact: | |
name: Indra Saputra | |
url: https://github.com/indrasaputra | |
license: | |
name: BSD 3-Clause License | |
url: https://github.com/indrasaputra/arjuna/blob/main/LICENSE | |
tags: | |
- name: AuthService | |
description: This service provides all use cases to work with auth. | |
- name: TransactionCommandService | |
description: This service provides all use cases to work with transaction. | |
- name: UserCommandService | |
description: This service provides basic command or state-changing use cases to work with user.A user is represented by an email as its unique identifier. | |
- name: UserCommandInternalService | |
description: It is the same as UserCommand but should be used internally and not exposed to public. | |
- name: UserQueryService | |
description: This service provides basic query or data-retrieving use cases to work with user. | |
- name: WalletCommandService | |
description: This service provides all use cases to work with wallet. | |
host: localhost:8000 | |
schemes: | |
- http | |
consumes: | |
- application/json | |
produces: | |
- application/json | |
paths: | |
/v1/auth/login: | |
post: | |
summary: Login. | |
description: |- | |
This endpoint logs in an account. | |
As of now, refresh token is not implemented and it only returns access token. | |
operationId: Login | |
responses: | |
"200": | |
description: A successful response. | |
schema: | |
$ref: '#/definitions/v1LoginResponse' | |
default: | |
description: An unexpected error response. | |
schema: | |
$ref: '#/definitions/rpcStatus' | |
parameters: | |
- name: credential | |
description: credential represents credential for login. | |
in: body | |
required: true | |
schema: | |
$ref: '#/definitions/v1Credential' | |
required: | |
- credential | |
tags: | |
- Auth | |
/v1/transactions: | |
post: | |
summary: CreateTransaction. | |
description: This endpoint creates a transaction. | |
operationId: CreateTransaction | |
responses: | |
"200": | |
description: A successful response. | |
schema: | |
$ref: '#/definitions/v1CreateTransactionResponse' | |
default: | |
description: An unexpected error response. | |
schema: | |
$ref: '#/definitions/rpcStatus' | |
parameters: | |
- name: transaction | |
description: transaction represents transaction data. | |
in: body | |
required: true | |
schema: | |
$ref: '#/definitions/v1Transaction' | |
- name: Authorization | |
in: header | |
required: true | |
type: string | |
- name: X-Idempotency-Key | |
in: header | |
required: true | |
type: string | |
tags: | |
- Transaction | |
/v1/users: | |
get: | |
summary: Get all users. | |
description: |- | |
This endpoint gets all available users in the system. | |
Currently, it only retrieves 10 users at most. | |
operationId: GetAllUsers | |
responses: | |
"200": | |
description: A successful response. | |
schema: | |
$ref: '#/definitions/v1GetAllUsersResponse' | |
default: | |
description: An unexpected error response. | |
schema: | |
$ref: '#/definitions/rpcStatus' | |
parameters: | |
- name: limit | |
description: limit specifies how many users to retrieve in a single call. | |
in: query | |
required: false | |
type: integer | |
format: int64 | |
- name: Authorization | |
in: header | |
required: true | |
type: string | |
tags: | |
- User | |
/v1/users/register: | |
post: | |
summary: Register a new user. | |
description: |- | |
This endpoint registers a new user. | |
The X-Idempotency-Key header must be present. | |
operationId: RegisterUser | |
responses: | |
"200": | |
description: A successful response. | |
schema: | |
$ref: '#/definitions/v1RegisterUserResponse' | |
default: | |
description: An unexpected error response. | |
schema: | |
$ref: '#/definitions/rpcStatus' | |
parameters: | |
- name: user | |
description: user represents user data. | |
in: body | |
required: true | |
schema: | |
$ref: '#/definitions/v1User' | |
required: | |
- user | |
- name: X-Idempotency-Key | |
in: header | |
required: true | |
type: string | |
tags: | |
- User | |
/v1/wallets/topups: | |
put: | |
summary: Topup. | |
description: This endpoint topups a wallet. | |
operationId: TopupWallet | |
responses: | |
"200": | |
description: A successful response. | |
schema: | |
$ref: '#/definitions/v1TopupWalletResponse' | |
default: | |
description: An unexpected error response. | |
schema: | |
$ref: '#/definitions/rpcStatus' | |
parameters: | |
- name: topup | |
description: topup represents topup data. | |
in: body | |
required: true | |
schema: | |
$ref: '#/definitions/v1Topup' | |
required: | |
- topup | |
- name: Authorization | |
in: header | |
required: true | |
type: string | |
- name: X-Idempotency-Key | |
in: header | |
required: true | |
type: string | |
tags: | |
- Wallet | |
/v1/wallets/transfers: | |
put: | |
summary: TransferBalance. | |
description: This endpoint transfers balance from one wallet to another wallet. | |
operationId: TransferWallet | |
responses: | |
"200": | |
description: A successful response. | |
schema: | |
$ref: '#/definitions/v1TransferBalanceResponse' | |
default: | |
description: An unexpected error response. | |
schema: | |
$ref: '#/definitions/rpcStatus' | |
parameters: | |
- name: transfer | |
description: transfer represents transfer data. | |
in: body | |
required: true | |
schema: | |
$ref: '#/definitions/v1Transfer' | |
- name: Authorization | |
in: header | |
required: true | |
type: string | |
- name: X-Idempotency-Key | |
in: header | |
required: true | |
type: string | |
tags: | |
- Wallet | |
definitions: | |
protobufAny: | |
type: object | |
properties: | |
'@type': | |
type: string | |
additionalProperties: {} | |
rpcStatus: | |
type: object | |
properties: | |
code: | |
type: integer | |
format: int32 | |
message: | |
type: string | |
details: | |
type: array | |
items: | |
type: object | |
$ref: '#/definitions/protobufAny' | |
v1Account: | |
type: object | |
properties: | |
id: | |
type: string | |
example: 01917a0c-475e-7d4a-9ec1-a56d14d78569 | |
description: id represents unique id. | |
readOnly: true | |
user_id: | |
type: string | |
format: string | |
example: 01917a0c-cdfe-7696-9259-1c9821c8fd73 | |
description: User's id | |
email: | |
type: string | |
example: [email protected] | |
description: User's email | |
pattern: ^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$ | |
password: | |
type: string | |
format: string | |
example: weakPassword | |
description: User's password | |
title: password represents user's password | |
description: Account represents account. | |
required: | |
- id | |
- user_id | |
v1CreateTransactionResponse: | |
type: object | |
properties: | |
data: | |
$ref: '#/definitions/v1Transaction' | |
description: data represents transaction. | |
description: CreateTransactionResponse represents response from create transaction. | |
v1CreateWalletResponse: | |
type: object | |
description: CreateWalletResponse represents response from create wallet. | |
v1Credential: | |
type: object | |
properties: | |
email: | |
type: string | |
example: [email protected] | |
description: User's email | |
pattern: ^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$ | |
password: | |
type: string | |
format: string | |
example: weakPassword | |
description: User's password | |
description: Credential represents login credential. | |
required: | |
- password | |
v1DeleteUserResponse: | |
type: object | |
description: DeleteUserResponse represents response from delete user. | |
v1GetAllUsersResponse: | |
type: object | |
properties: | |
data: | |
type: array | |
items: | |
type: object | |
$ref: '#/definitions/v1User' | |
description: data represents an array of user data. | |
description: GetAllUsersResponse represents response from get all users. | |
v1LoginResponse: | |
type: object | |
properties: | |
data: | |
$ref: '#/definitions/v1Token' | |
description: data represents token. | |
description: LoginResponse represents response from login. | |
v1RegisterAccountResponse: | |
type: object | |
description: RegisterAccountResponse represents response for account registration. | |
v1RegisterUserResponse: | |
type: object | |
properties: | |
data: | |
$ref: '#/definitions/v1User' | |
description: data represents user. | |
description: RegisterUserResponse represents response from register user. | |
v1Token: | |
type: object | |
properties: | |
access_token: | |
type: string | |
description: access_token represents an access token. | |
readOnly: true | |
access_token_expires_in: | |
type: integer | |
format: int64 | |
description: access_token_expires_in represents how many seconds left before access token expired. | |
readOnly: true | |
refresh_token: | |
type: string | |
description: refresh_token represents an refresh token. | |
readOnly: true | |
refresh_token_expires_in: | |
type: integer | |
format: int64 | |
description: refresh_token_expires_in represents how many seconds left before refresh token expired. | |
readOnly: true | |
description: Token represents token. | |
required: | |
- access_token | |
- access_token_expires_in | |
- refresh_token | |
- refresh_token_expires_in | |
v1Topup: | |
type: object | |
properties: | |
wallet_id: | |
type: string | |
example: 01917a0c-cdfe-701e-9547-ed45a24d7c84 | |
description: Wallet's id | |
amount: | |
type: string | |
example: "10.23" | |
description: Topup amount | |
description: Topup represents topup. | |
required: | |
- wallet_id | |
- amount | |
v1TopupWalletResponse: | |
type: object | |
description: TopupWalletResponse represents response from topup wallet. | |
v1Transaction: | |
type: object | |
properties: | |
id: | |
type: string | |
example: 01917a0c-cdfe-7d3c-b0fc-ea83671bf6d9 | |
description: id represents unique id. | |
readOnly: true | |
sender_id: | |
type: string | |
example: 01917a0c-cdfe-7ce9-a9aa-a921cfd6c289 | |
description: Transaction's sender's id | |
receiver_id: | |
type: string | |
example: 01917a0c-cdfe-7f72-9b8f-12c3480d5baf | |
description: Transaction's receiver's id | |
amount: | |
type: string | |
example: "10.23" | |
description: Transaction's amount | |
created_at: | |
type: string | |
format: date-time | |
description: created_at represents when the transaction was created. | |
readOnly: true | |
description: Transaction represents transaction. | |
v1Transfer: | |
type: object | |
properties: | |
sender_id: | |
type: string | |
example: 01917a10-1086-74a6-8cfb-0074f65bebe3 | |
description: Sender's id | |
sender_wallet_id: | |
type: string | |
example: 01917a10-1086-7faa-9c9e-0bf6a9cf6928 | |
description: Sender's wallet's id | |
receiver_id: | |
type: string | |
example: 01917a10-1086-7c94-93c4-32de26621dae | |
description: Receiver's id | |
receiver_wallet_id: | |
type: string | |
example: 01917a10-1086-72df-818a-b72d663fb3b5 | |
description: Receiver's wallet's id | |
amount: | |
type: string | |
example: "10.23" | |
description: Transfer amount | |
description: Transfer represents transfer. | |
required: | |
- sender_id | |
- sender_wallet_id | |
- receiver_id | |
- receiver_wallet_id | |
- amount | |
v1TransferBalanceResponse: | |
type: object | |
description: TransferBalanceResponse represents response from transfer balance. | |
v1User: | |
type: object | |
properties: | |
id: | |
type: string | |
example: 01917a0c-cdfe-7e4f-9692-635eb6a6f358 | |
description: id represents a user's id. | |
readOnly: true | |
email: | |
type: string | |
example: [email protected] | |
description: user's email | |
pattern: ^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$ | |
password: | |
type: string | |
format: string | |
example: WEAKpassword123? | |
description: user's password | |
name: | |
type: string | |
example: First User | |
description: user's name | |
maxLength: 255 | |
minLength: 1 | |
created_at: | |
type: string | |
format: date-time | |
description: created_at represents when the user was registered. | |
readOnly: true | |
updated_at: | |
type: string | |
format: date-time | |
description: updated_at represents when the user was last updated. | |
readOnly: true | |
description: User represents a user data. | |
required: | |
- password | |
- name | |
v1Wallet: | |
type: object | |
properties: | |
id: | |
type: string | |
example: 01917a0c-cdfe-74dd-9d95-4d87b5d1f0b8 | |
description: id represents unique id. | |
readOnly: true | |
user_id: | |
type: string | |
example: 01917a0c-cdfe-7aae-b311-a8c7c32f5c70 | |
description: Wallet's user's id | |
balance: | |
type: string | |
example: "10.23" | |
description: Wallet's balance | |
description: Wallet represents wallet. | |
required: | |
- user_id | |
- balance |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment