Skip to content

Instantly share code, notes, and snippets.

@Lauviah0622
Last active October 19, 2021 14:57
Show Gist options
  • Save Lauviah0622/79cd6dd229857f8cb2aa02c5bdcf37a7 to your computer and use it in GitHub Desktop.
Save Lauviah0622/79cd6dd229857f8cb2aa02c5bdcf37a7 to your computer and use it in GitHub Desktop.
long Island order API
openapi: 3.0.1
info:
title: Order API
description: >-
Order API practice
termsOfService: http://swagger.io/terms/
contact:
email: apiteam@swagger.io
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
version: 1.0.0
externalDocs:
description: Find out more about Swagger
url: http://swagger.io
servers:
- url: https://store.io/
- url: http://store.io/
tags:
- name: order
description: about order
paths:
/order:
get:
tags:
- order
parameters:
- $ref: '#/components/parameters/orderId'
summary: 查詢訂單
operationId: getOrder
responses:
'200':
description: get id success
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
'404':
description: order Id not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorNotFound'
post:
tags:
- order
summary: create new order
operationId: addOrder
security:
- MemberCookieAuth: []
requestBody:
description: order Object
content:
application/json:
schema:
type: object
properties:
orderer:
$ref: '#/components/schemas/Orderer'
list:
type: array
items:
$ref: '#/components/schemas/Product'
required: true
responses:
'200':
description: success
content:
application/json:
schema:
type: object
properties:
id:
type: integer
minimum: 0
orderer:
$ref: "#/components/schemas/Orderer"
status:
type: string
enum:
- success
- fail
- paid
productList:
type: array
items:
$ref: "#/components/schemas/Product"
createdAt:
type: string
format: date-time
paidAt:
type: string
format: date-time
example: null
lastUpdatedAt:
type: string
format: date-time
example: null
patch:
tags:
- order
summary: update order
operationId: updateOrder
security:
- MemberCookieAuth: []
parameters:
- $ref: '#/components/parameters/orderId'
requestBody:
content:
application/json:
schema:
type: object
properties:
status:
$ref: '#/components/schemas/OrderStatus'
example: paid
required: true
responses:
'200':
description: success
content:
application/json:
schema:
$ref: '#/components/schemas/Order'
'400':
$ref: '#/components/responses/IdNotFound'
delete:
tags:
- order
summary: delete order
security:
- MemberCookieAuth: []
operationId: deleteOrder
parameters:
- $ref: '#/components/parameters/orderId'
responses:
'200':
description: success
content:
application/json:
schema:
type: object
properties:
deleteId:
type: integer
minimum: 0
'400':
$ref: '#/components/responses/IdNotFound'
/orders:
get:
tags:
- orders
summary: search orders
security:
- AdminCookieAuth: []
operationId: getOrders
parameters:
- in: query
name: email
required: false
schema:
type: string
responses:
'200':
description: success
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Order"
components:
schemas:
Order:
type: object
properties:
id:
type: integer
format: int64
example: 1
orderer:
$ref: "#/components/schemas/Orderer"
status:
$ref: "#/components/schemas/OrderStatus"
productList:
type: array
items:
type: object
properties:
product:
$ref: "#/components/schemas/Product"
quantity:
type: integer
minimum: 1
createdAt:
nullable: true
paidAt:
type: string
format: date-time
lastUpdatedAt:
nullable: true
type: string
format: date-time
ErrorNotFound:
type: string
enum:
- Endpoint not found
OrderStatus:
type: string
enum:
- unpaid
- fail
- paid
Product:
type: object
properties:
id:
type: number
format: int64
minimum: 1
name:
type: string
example: Apple
price:
type: integer
minimum: 1
exclusiveMinimum: false
example: 123
Orderer:
type: object
properties:
name:
type: string
example: Jessica Chen
email:
type: string
format: email
example: lavi@gmail.com
phone:
type: string
example: 0987654321
parameters:
orderId:
name: orderId
in: query
required: true
schema:
type: number
description: 輸入 oreder ID
responses:
IdNotFound:
description: The order ID is not found
content:
application/json:
schema:
type: string
enum:
- "Id Not Found"
securitySchemes:
MemberCookieAuth:
type: apiKey
in: cookie
name: MEMBER_SESSION_ID
AdminCookieAuth:
type: apiKey
in: cookie
name: ADMIN_SESSION_ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment