· 6 years ago · Nov 09, 2019, 12:54 AM
1swagger: "2.0"
2info:
3 description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."
4 version: "1.0.0"
5 title: "Swagger example"
6 termsOfService: "http://swagger.io/terms/"
7 contact:
8 email: "apiteam@swagger.io"
9 license:
10 name: "Apache 2.0"
11 url: "http://www.apache.org/licenses/LICENSE-2.0.html"
12host: "petstore.swagger.io"
13basePath: "/v2"
14tags:
15- name: "users"
16 description: "task management users"
17- name: "tasks"
18 description: "task management tasks"
19schemes:
20- "https"
21- "http"
22
23paths:
24 /users:
25
26 post:
27 tags:
28 - "users"
29 summary: "add a new user"
30 description: ""
31 operationId: "addUser"
32 consumes:
33 - "application/json"
34 - "application/xml"
35 produces:
36 - "application/json"
37 - "application/xml"
38 parameters:
39 - in: "body"
40 name: "body"
41 schema:
42 type: "array"
43 items:
44 $ref: "#/definitions/User"
45 responses:
46 200:
47 description: "list of users"
48 400:
49 description: "invalid parameter"
50 404:
51 description: "user not found"
52 500:
53 description: "internal service error"
54
55 get:
56 responses:
57 200:
58 description: "success"
59 schema:
60 type: "object"
61 items:
62 $ref: "#/definitions/User"
63 400:
64 description: "invalid parameter"
65 404:
66 description: "user not found"
67 500:
68 description: "internal service error"
69
70 put:
71 tags:
72 - "users"
73 parameters:
74 - in: "path"
75 type: "integer"
76 name: "uid"
77 description: "asdf"
78 required: true
79 responses:
80 405:
81 description: "Method not allowed"
82
83 delete:
84 tags:
85 - "users"
86 parameters:
87 - name: "uid"
88 in: "path"
89 type: "integer"
90 description: "none"
91 required: true
92 responses:
93 405:
94 description: "Method not allowed"
95
96 /users/{uid}:
97
98 post:
99 tags:
100 - "users"
101 summary: "new user"
102 description: ""
103 operationId: "postUser"
104 consumes:
105 - "application/json"
106 - "application/xml"
107 parameters:
108 - name: "uid"
109 in: "path"
110 description: "user id"
111 required: true
112 type: "integer"
113 format: "int64"
114 - name: "first_name"
115 in: "body"
116 description: "new user name"
117 required: false
118 schema:
119 $ref: "#/definitions/User"
120 responses:
121 200:
122 description: "success"
123 400:
124 description: "invalid parameter"
125
126 get:
127 tags:
128 - "users"
129 summary: "get a user"
130 description: ""
131 operationId: "getUser"
132 produces:
133 - "application/xml"
134 - "application/json"
135 parameters:
136 - name: "uid"
137 in: "path"
138 description: "user id"
139 required: true
140 type: "integer"
141 format: "int64"
142 responses:
143 200:
144 description: "success"
145 schema:
146 $ref: "#/definitions/User"
147 400:
148 description: "invalid parameter"
149 404:
150 description: "user not found"
151 500:
152 description: "internal service error"
153
154 put:
155 tags:
156 - "users"
157 summary: "updates user"
158 description: ""
159 operationId: "updateUser"
160 consumes:
161 - "application/json"
162 - "application/xml"
163 parameters:
164 - name: "uid"
165 in: "path"
166 description: "user id"
167 required: true
168 type: "integer"
169 format: "int64"
170 - name: "firstname"
171 in: "body"
172 description: "new user name"
173 required: false
174 schema:
175 $ref: "#/definitions/User"
176 responses:
177 200:
178 description: "success"
179 400:
180 description: "invalid parameter"
181 404:
182 description: "user not found"
183
184 delete:
185 tags:
186 - "users"
187 summary: "deletes user"
188 description: ""
189 operationId: "deleteUser"
190 produces:
191 - "application/xml"
192 - "application/json"
193 parameters:
194 - name: "uid"
195 in: "path"
196 description: "user id"
197 required: true
198 type: "integer"
199 format: "int64"
200 responses:
201 200:
202 description: "success"
203 400:
204 description: "invalid parameter"
205 404:
206 description: "user not found"
207
208 /users/{uid}/tasks:
209
210 post:
211 tags:
212 - "tasks"
213 summary: "add a task"
214 description: ""
215 operationId: "makeTask"
216 consumes:
217 - "application/json"
218 - "application/xml"
219 parameters:
220 - name: "uid"
221 in: "path"
222 description: "user id"
223 required: true
224 type: "integer"
225 format: "int64"
226 - name: "task"
227 in: "body"
228 description: "new task"
229 required: true
230 schema:
231 $ref: "#/definitions/Task"
232 responses:
233 200:
234 description: "success"
235 400:
236 description: "invalid parameter"
237 404:
238 description: "user not found"
239
240 get:
241 tags:
242 - "tasks"
243 summary: "get tasks"
244 description: ""
245 operationId: "getTasks"
246 produces:
247 - "application/xml"
248 - "application/json"
249 parameters:
250 - name: "uid"
251 in: "path"
252 description: "user id"
253 required: true
254 type: "integer"
255 format: "int64"
256 responses:
257 200:
258 description: "success"
259 schema:
260 type: "object"
261 items:
262 $ref: "#/definitions/Task"
263 400:
264 description: "invalid parameter"
265 404:
266 description: "user not found"
267
268 put:
269 tags:
270 - "tasks"
271 parameters:
272 - in: "path"
273 type: "integer"
274 name: "uid"
275 description: "none"
276 required: true
277 responses:
278 405:
279 description: "Method not allowed"
280 delete:
281 tags:
282 - "tasks"
283 parameters:
284 - in: "path"
285 type: "integer"
286 name: "uid"
287 description: "none"
288 required: true
289 responses:
290 405:
291 description: "Method not allowed"
292
293 /users/{uid}/tasks/{tid}:
294 post:
295 tags:
296 - "tasks"
297 parameters:
298 - in: "path"
299 type: "integer"
300 name: "uid"
301 description: "none"
302 required: true
303 - in: "path"
304 type: "integer"
305 name: "tid"
306 description: "none"
307 required: true
308 responses:
309 405:
310 description: "Method not allowed"
311 # get:
312 # put:
313 # delete:
314
315
316definitions:
317 User:
318 type: "object"
319 properties:
320 uid:
321 type: "integer"
322 format: "int64"
323 first_name:
324 type: "string"
325 format: "string"
326 Task:
327 type: "object"
328 properties:
329 tid:
330 type: "integer"
331 format: "int64"
332 content:
333 type: "string"
334 format: "string"