Skip to content

Instantly share code, notes, and snippets.

@jamby1100
Created March 24, 2021 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamby1100/66ae6b19cb5e9642d92a7e29cbf4bcb3 to your computer and use it in GitHub Desktop.
Save jamby1100/66ae6b19cb5e9642d92a7e29cbf4bcb3 to your computer and use it in GitHub Desktop.
OpenAPI 3.0 definition for Simple Loyalty Application
openapi: 3.0.0
info:
title: Loyalty Card API
version: "0.1"
components:
schemas:
User:
type: object
properties:
id:
type: string
first_name:
type: string
last_name:
type: string
email:
type: string
user_type:
type: string
Transaction:
type: object
properties:
id:
type: string
amount:
type: number
equivalent_points:
type: number
card_id:
type: string
partner_id:
type: string
Card:
type: object
properties:
id:
type: string
card_number:
type: string
state:
type: string
originator_partner_id:
type: string
user_id:
type: string
Partner:
type: object
properties:
id:
type: string
name:
type: string
address:
type: string
paths:
/transactions:
post:
summary: create transaction
tags:
- Transactions
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Transaction'
responses:
'201':
description: Created Transaction
headers:
Location:
schema:
type: string
get:
summary: Get all transactions
tags:
- Transactions
parameters:
- name: "partner_id"
in: "query"
description: ""
required: false
schema:
type: integer
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/Transaction'
/partners:
post:
summary: create partner establishments
tags:
- Partners
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Partner'
responses:
'201':
description: Created partner
headers:
Location:
schema:
type: string
get:
summary: Get all partners
tags:
- Partners
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/Partner'
/users:
post:
summary: Create User
tags:
- Users
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/User'
responses:
'201':
description: Created user
headers:
Location:
schema:
type: string
get:
summary: Get all users
tags:
- Users
parameters:
- name: "state"
in: "query"
description: "Query for cardless users"
required: false
schema:
type: string
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/User'
/users/{user_id}/cards/{card_id}:claim_card:
parameters:
- schema:
type: string
name: user_id
in: path
required: true
- schema:
type: string
name: card_id
in: path
required: true
post:
description: Claim a card
tags:
- Cards
requestBody:
content:
application/json:
schema:
type: object
properties:
partner_id:
type: string
example: bistro_group
notes:
type: string
example: The customer claimed printed ticket
responses:
'200':
description: Claim the card
content:
application/json:
schema:
type: object
properties:
card_claimed:
type: boolean
example: true
/users/{user_id}/cards/:
parameters:
- schema:
type: string
name: user_id
in: path
required: true
post:
summary: create card for a user
tags:
- Cards
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Card'
responses:
'201':
description: Created user
headers:
Location:
schema:
type: string
get:
summary: Get all cards for a user
tags:
- Cards
parameters:
- name: "partner_id"
in: "query"
description: ""
required: false
schema:
type: integer
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: '#/components/schemas/Card'
/transactions/{id}:
parameters:
- schema:
type: integer
name: id
in: path
required: true
get:
summary: View Transaction
tags:
- Transactions
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Transaction'
/users/{id}:compute_points:
parameters:
- schema:
type: integer
name: id
in: path
required: true
get:
summary: View Transaction
tags:
- Users
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
properties:
points:
type: number
/users:signin:
post:
tags:
- Users
description: Create a new token
requestBody:
content:
application/json:
schema:
type: object
properties:
username:
type: string
example: jamby1100
password:
type: string
example: password
responses:
'201':
description: Create new token
content:
application/json:
schema:
type: object
properties:
token:
type: string
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment