Files
whale-web/openapi.yaml
2021-05-19 10:20:43 +08:00

475 lines
12 KiB
YAML

openapi: 3.0.3
info:
title: Bluewhale
description: 'This is API specifications for bluewhale site'
version: 1.0.0
servers:
- url: http://127.0.0.1:4010
paths:
"/api/v1/me":
get:
summary: get current user's profile
responses:
'200':
description: current user
content:
application/json:
schema:
type: object
properties:
data:
$ref: "#/components/schemas/User"
code:
type: integer
"/api/v1/login":
options:
summary: get csrf token
responses:
'200':
description: options
post:
summary: login
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/LoginForm"
responses:
'200':
description: success login
content:
application/json:
schema:
type: object
properties:
data:
$ref: "#/components/schemas/User"
code:
type: integer
"/api/v1/logout":
post:
summary: logout
responses:
'200':
description: success logout
"/api/v1/send-verification":
post:
summary: send verification mail
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/SendVerificationForm"
responses:
'200':
description: success send verification
content:
application/json:
schema:
type: object
properties:
data:
type: integer
code:
type: integer
"/api/v1/verify/{token}":
get:
summary: get verified email from token
parameters:
- in: path
name: token
schema:
type: string
required: true
description: string token
responses:
'200':
description: success get verified token
content:
application/json:
schema:
type: object
properties:
data:
type: string
format: email
code:
type: integer
"/api/v1/register":
post:
summary: register user by token
requestBody:
content:
application/json:
schema:
type: object
properties:
token:
type: string
password:
type: string
responses:
'201':
description: success register user
content:
application/json:
schema:
type: object
properties:
data:
$ref: "#/components/schemas/User"
code:
type: integer
"/api/v1/articles":
get:
summary: get list of articles
responses:
'200':
description: success get articles
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/Article"
code:
type: integer
post:
summary: post one article
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Article"
responses:
'201':
description: success post one article
content:
application/json:
schema:
type: object
properties:
data:
$ref: "#/components/schemas/Article"
code:
type: integer
"/api/v1/articles/{pk}":
summary: fetch/edit/delete one article
parameters:
- in: path
name: pk
schema:
type: string
required: true
description: primary key
get:
summary: fetch one article
responses:
'200':
description: success get one article
content:
application/json:
schema:
type: object
properties:
data:
$ref: "#/components/schemas/Article"
code:
type: integer
put:
summary: edit one article
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Article"
responses:
'200':
description: success edit one article
content:
application/json:
schema:
$ref: "#/components/schemas/Article"
delete:
summary: delete one article
responses:
'204':
description: success delete one article
"/api/v1/users":
get:
summary: get list of users
responses:
'200':
description: success get users
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/User"
code:
type: integer
post:
summary: add one user by admin
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/User"
responses:
'201':
description: success add one user
content:
application/json:
schema:
type: object
properties:
data:
$ref: "#/components/schemas/User"
code:
type: integer
"/api/v1/users/{pk}":
summary: fetch/edit/delete one user
parameters:
- in: path
name: pk
schema:
type: integer
required: true
description: primary key
get:
summary: fetch one user
responses:
'200':
description: success get one user
content:
application/json:
schema:
type: object
properties:
data:
$ref: "#/components/schemas/User"
code:
type: integer
put:
summary: edit one user
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/User"
responses:
'200':
description: success edit one user
content:
application/json:
schema:
$ref: "#/components/schemas/User"
delete:
summary: delete one user
responses:
'204':
description: success delete one user
"/api/v1/competitions":
get:
summary: get list of competitions
responses:
'200':
description: success get competitions
content:
application/json:
schema:
type: object
properties:
data:
type: array
items:
$ref: "#/components/schemas/Competition"
code:
type: integer
post:
summary: post one competition
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Competition"
responses:
'201':
description: success post one competition
content:
application/json:
schema:
type: object
properties:
data:
$ref: "#/components/schemas/Competition"
code:
type: integer
"/api/v1/competitions/{pk}":
summary: fetch/edit/delete one competition
parameters:
- in: path
name: pk
schema:
type: string
required: true
description: primary key
get:
summary: fetch one competition
responses:
'200':
description: success get one competition
content:
application/json:
schema:
type: object
properties:
data:
$ref: "#/components/schemas/Competition"
code:
type: integer
put:
summary: edit one competition
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/Competition"
responses:
'200':
description: success edit one competition
content:
application/json:
schema:
$ref: "#/components/schemas/Competition"
delete:
summary: delete one competition
responses:
'204':
description: success delete one competition
components:
schemas:
CommonResponse: # common response which has data and code properties
type: object
properties:
data:
type: object
code:
type: integer
LoginForm:
type: object
properties:
email:
type: string
format: email
password:
type: string
format: password
SendVerificationForm:
type: object
properties:
email:
type: string
format: email
User:
type: object
properties:
id:
type: integer
format: int64
minimum: 1
email:
type: string
format: email
phone:
type: string
nickname:
type: string
date_joined:
type: string
format: date-time
last_login:
type: string
format: date-time
last_login_ip:
type: string
format: ipv4
description:
type: string
avatar: # 头像
type: string
school: # 学校
type: string
speciality: # 专业
type: string
wechat: # 微信号
type: string
company: # 公司
type: string
title: # 职位
type: string
groups:
type: array
items:
$ref: "#/components/schemas/Group"
Group:
type: object
properties:
id:
type: integer
format: int64
minimum: 1
name:
type: string
Article:
type: object
properties:
id:
type: string
format: uuid
author:
type: string
format: email
title:
type: string
content:
type: string
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
status:
type: integer
enum: [0,1,2]
Competition:
type: object
properties:
id:
type: string
format: uuid
author:
type: string
format: email
title:
type: string
content:
type: string
created_at:
type: string
format: date-time
updated_at:
type: string
format: date-time
status:
type: integer
enum: [0,1,2]