-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.yaml
More file actions
196 lines (192 loc) · 4.38 KB
/
example.yaml
File metadata and controls
196 lines (192 loc) · 4.38 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
openapi: 3.0.1
info:
title: 测试文档
description: 测试文档
version: 0.0.1
servers:
- url: 'http://localhost:3000/api'
description: 测试api
tags:
- name: User
description: 用户的Restful api
paths:
/users:
get:
tags:
- User
summary: List users
description: 获取用户列表
operationId: listUsers
parameters:
- name: name
in: query
description: 用户名称
required: false
schema:
type: string
example: user1
- name: limit
in: query
description: 返回数量
required: false
schema:
type: integer
example: 10
- name: offset
in: query
description: 偏移量
required: false
schema:
type: integer
example: 0
responses:
'200':
description: OK
headers:
X-Total:
schema:
description: 当前查询包含的总数
type: integer
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/User'
post:
tags:
- User
summary: Create user
description: 新建用户
operationId: createUser
requestBody:
description: 用户
content:
application/json:
schema:
type: object
properties:
name:
type: string
examples:
newUser:
summary: 新建用户示例
value:
name: New User
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/User'
/users/{userId}:
get:
tags:
- User
summary: Get user by id
description: 获取用户
operationId: getUserById
parameters:
- in: path
schema:
type: string
required: true
description: 用户id
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/User'
404:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
put:
tags:
- User
summary: Update user by id
operationId: updateUserById
description: 更新用户
requestBody:
description: 用户
content:
application/json:
schema:
type: object
properties:
name:
type: string
examples:
newUser:
summary: 更新用户示例
value:
name: Updated User
parameters:
- in: path
schema:
type: string
required: true
description: 用户id
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/User'
404:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
tags:
- User
summary: Delete user
description: 删除用户
operationId: deleteUser
parameters:
- in: path
schema:
type: string
required: true
description: 用户id
responses:
204:
description: Delete Ok
404:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
components:
responses:
SingleUserResp:
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/User'
NotFound:
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
schemas:
User:
type: object
properties:
id:
type: string
name:
type: string
Error:
type: object
properties:
name:
type: string
message:
type: string