-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.yml
92 lines (89 loc) · 2.47 KB
/
sample.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
openapi: 3.0.0
info:
description: Example API
version: 0.0.1
#use a extention tag x-test on top level to declare some fixtures:
x-test:
# prop:['before']will be put to the front of every test files.
before: |
let token
async function requestToken() {
let res = await request.post("/user/login")
.type('json')
.send({
name: "Andy",
password: "12345678"
})
assert.equal(res.statusCode, 200)
token = res.body.token
}
# prop:['beforeEach']will be put to the front of every testSuite.
beforeEach: |
static async before() { await requestToken() }
paths:
/user:
get:
operationId: userList
description: "get user list"
parameters:
- in: query
name: pageIndex
schema:
type: integer
format: int32
- in: query
name: pageSize
schema:
type: integer
format: int32
responses:
'200':
description: return user list
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/Page'
- type: object
properties:
data:
$ref: '#/components/schemas/UserList'
# x-test at here declare a single testcase:
x-test:
# 'getUserList' is the name of this testcase:
getUserList:
parameters:
page_index: 1
page_size: 20
'/user/{id}':
put:
operationId: editUser
description: edit an user object
parameters:
- name: id
in: path
description: user_id
required: true
schema:
type: integer
format: int64
responses:
'200':
description: return an user object
content:
application/json:
schema:
$ref: '#/components/schemas/User'
x-test:
editUser:
headers: |
"Authorization": "Bearer " + token
before: |
console.log('just a test!')
uri-parameters:
id: 1
body:
name: mark
email: [email protected]
after: |
assert.equal(res.body.name, "Andy")