Skip to content

Instantly share code, notes, and snippets.

@pubudu538
Last active July 26, 2025 07:29
Show Gist options
  • Select an option

  • Save pubudu538/7de5cbcdb894de81853ade41f838df8f to your computer and use it in GitHub Desktop.

Select an option

Save pubudu538/7de5cbcdb894de81853ade41f838df8f to your computer and use it in GitHub Desktop.
openapi: 3.0.1
info:
title: Accounts API
description: API to manage customer accounts
contact: {}
version: 1.0.0
servers:
- url: http://accounts.gub.com/grand-union-bank-unity/accounts-service/v1.0
paths:
/accounts:
get:
summary: Get all accounts
tags:
- accounts
responses:
'200':
description: List of accounts
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Account'
post:
tags:
- accounts
summary: Create a new account
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/AccountCreate'
required: true
responses:
'201':
description: Account created successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Account'
'400':
description: Invalid input
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/accounts/{id}:
get:
tags:
- accounts
summary: Get account by ID
responses:
'200':
description: Account found
content:
application/json:
schema:
$ref: '#/components/schemas/Account'
'400':
description: Invalid ID supplied
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Account not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
put:
tags:
- accounts
summary: Update account by ID
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/AccountUpdate'
required: true
responses:
'200':
description: Account updated successfully
content:
application/json:
schema:
$ref: '#/components/schemas/Account'
'400':
description: Invalid input
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Account not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
delete:
tags:
- accounts
summary: Delete account by ID
responses:
'200':
description: Account deleted successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Account 1 deleted.
'400':
description: Invalid ID supplied
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Account not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
parameters:
- name: id
in: path
description: Account ID
required: true
style: simple
explode: false
schema:
type: integer
example: 1
/accounts/{id}/balance:
get:
tags:
- accounts
summary: Get account balance
parameters:
- name: id
in: path
required: true
style: simple
explode: false
schema:
type: integer
example: 1
responses:
'200':
description: Account balance retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/AccountBalance'
'404':
description: Account not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/accounts/{id}/transactions:
get:
tags:
- accounts
summary: Get account transaction history
parameters:
- name: id
in: path
required: true
style: simple
explode: false
schema:
type: integer
example: 1
responses:
'200':
description: Transaction history retrieved
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Transaction'
'404':
description: Account not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
Account:
type: object
properties:
accountType:
type: string
enum:
- savings
- current
example: savings
balance:
type: number
format: float
example: 5000
createdAt:
type: string
format: date-time
example: '2024-01-10T09:00:00Z'
customerId:
type: string
example: CUST1001
id:
type: integer
example: 1
status:
type: string
enum:
- active
- closed
- suspended
example: active
AccountBalance:
type: object
properties:
accountId:
type: integer
example: 1
balance:
type: number
format: float
example: 5000
currency:
type: string
example: LKR
AccountCreate:
type: object
properties:
accountType:
type: string
enum:
- savings
- current
example: savings
balance:
type: number
format: float
example: 5000
customerId:
type: string
example: CUST1001
status:
type: string
enum:
- active
- closed
- suspended
example: active
required:
- accountType
- balance
- customerId
- status
AccountUpdate:
type: object
properties:
accountType:
type: string
enum:
- savings
- current
example: savings
balance:
type: number
format: float
example: 5000
customerId:
type: string
example: CUST1001
status:
type: string
enum:
- active
- closed
- suspended
example: active
ErrorResponse:
type: object
properties:
error:
type: string
example: Invalid input
Transaction:
type: object
properties:
accountId:
type: integer
example: 1
amount:
type: number
format: float
example: 1500
description:
type: string
example: Utility bill payment
timestamp:
type: string
format: date-time
example: '2024-01-12T10:30:00Z'
transactionId:
type: string
example: TXN12345
type:
type: string
enum:
- credit
- debit
example: debit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment