blob: 721515242ece80de83b109afd675108e0e80eaa7 [file] [log] [blame]
刘洪青483a21f2020-09-07 12:20:33 +08001# user-authorization-service-poa.v1.yaml
2#
3# 1. 创建服务
4# curl -i -s -X POST 'https://poa-sa.dev.supwisdom.com/v1/services' -H 'Content-Type: application/json' -d '{"id": "authz", "origin": "http://user-authorization-poa-svc.user-authorization-service.svc.cluster.local:8080", "name": "授权服务", "description": "授权服务"}'
5#
6# 2. 创建版本
7# curl -i -s -X POST 'https://poa-sa.dev.supwisdom.com/v1/services/authz/apiVersions/v1'
8#
9# 3. 上传OAS Yaml
10# curl -i -s -X POST 'https://poa-sa.dev.supwisdom.com/v1/services/authz/apiVersions/v1/apiSpecs' -H 'Content-Type: application/yaml' --data-binary @user-authorization-service-poa.v1.yaml
11#
12# 4. 发布版本
13# curl -i -s -X POST 'https://poa-sa.dev.supwisdom.com/v1/services/authz/apiVersions/v1/publish'
14#
15openapi: 3.0.2
16info:
17 title: User Authorization Service Platform Open APIs
18 version: v1
19 description: '用户授权服务 - 平台开放接口'
20servers:
21 - url: 'http://poa-test.paas.newcapec.cn/apis/authz/v1'
22 description: '演示环境'
23tags:
24 - name: Role
25 description: '角色'
26paths:
27
28 '/application/{applicationId}/roles':
29 get:
30 summary: 获取应用下的角色列表
31 description: 获取应用下的角色列表
32 operationId: loadApplicationRoles
33 tags:
34 - Role
35 security:
36 - oauth2:
37 - "authz:v1:readRole"
38 parameters:
39 - name: applicationId
40 in: path
41 required: true
42 description: 应用标识
43 schema:
44 type: string
45 responses:
46 '200':
47 description: 角色列表
48 content:
49 application/json:
50 schema:
51 $ref: '#/components/schemas/ApplicationRolesResponse'
52 default:
53 $ref: '#/components/responses/DefaultErrorResponse'
54
55
56 '/application/{applicationId}/role/{rolecode}/accounts':
57 get:
58 summary: 获取应用下的一个角色的用户帐号
59 description: 获取应用下的一个角色的用户帐号
60 operationId: loadApplicationRoleAccounts
61 tags:
62 - Role
63 security:
64 - oauth2:
65 - "authz:v1:readRole"
66 parameters:
67 - name: applicationId
68 in: path
69 required: true
70 description: 应用标识
71 schema:
72 type: string
73 - name: rolecode
74 in: path
75 required: true
76 description: 角色代码
77 schema:
78 type: string
79 - name: loadAll
80 in: query
81 required: false
82 description: 分页-是否返回所有(当为 true 时,不分页,参数 pageIndex、pageSize 无效)
83 schema:
84 type: boolean
85 default: false
86 - name: pageIndex
87 in: query
88 required: false
89 description: 分页-页码
90 schema:
91 type: integer
92 format: int32
93 default: 0
94 - name: pageSize
95 in: query
96 required: false
97 description: 分页-每页记录数
98 schema:
99 type: integer
100 format: int32
101 default: 1000
102 responses:
103 '200':
104 description: 用户的帐号ID
105 content:
106 application/json:
107 schema:
108 $ref: '#/components/schemas/ApplicationRoleAccountsResponse'
109 default:
110 $ref: '#/components/responses/DefaultErrorResponse'
111
112 '/application/{applicationId}/account/{username}/roles':
113 get:
114 summary: 获取用户帐号在某一应用下所拥有的角色
115 description: 获取用户帐号在某一应用下所拥有的角色
116 operationId: loadAccountApplicationRoles
117 tags:
118 - Role
119 security:
120 - oauth2:
121 - "authz:v1:readRole"
122 parameters:
123 - name: applicationId
124 in: path
125 required: true
126 description: 应用标识
127 schema:
128 type: string
129 - name: username
130 in: path
131 required: true
132 description: 用户名
133 schema:
134 type: string
135 responses:
136 '200':
137 description: 角色列表
138 content:
139 application/json:
140 schema:
141 $ref: '#/components/schemas/AccountApplicationRolesResponse'
142 default:
143 $ref: '#/components/responses/DefaultErrorResponse'
144
145 '/application/{applicationId}/roles/accounts':
146 post:
147 summary: 获取应用下的多个角色的用户帐号
148 description: 获取应用下的多个角色的用户帐号
149 operationId: loadAccountsByApplicationRole
150 tags:
151 - Role
152 security:
153 - oauth2:
154 - "authz:v1:readRole"
155 parameters:
156 - name: applicationId
157 in: path
158 required: true
159 description: 应用标识
160 schema:
161 type: string
162 - name: loadAll
163 in: query
164 required: false
165 description: 分页-是否返回所有(当为 true 时,不分页,参数 pageIndex、pageSize 无效)
166 schema:
167 type: boolean
168 default: false
169 - name: pageIndex
170 in: query
171 required: false
172 description: 分页-页码
173 schema:
174 type: integer
175 format: int32
176 default: 0
177 - name: pageSize
178 in: query
179 required: false
180 description: 分页-每页记录数
181 schema:
182 type: integer
183 format: int32
184 default: 1000
185 requestBody:
186 description: 角色IDs
187 required: true
188 content:
189 application/json:
190 schema:
191 type: array
192 items:
193 title: 角色ID
194 type: string
195 responses:
196 '200':
197 description: 用户的帐号ID
198 content:
199 application/json:
200 schema:
201 $ref: '#/components/schemas/ApplicationRolesAccountsResponse'
202 default:
203 $ref: '#/components/responses/DefaultErrorResponse'
204
205components:
206
207 # Security Schemes
208
209 securitySchemes:
210 oauth2:
211 type: oauth2
212 flows:
213 clientCredentials:
214 tokenUrl: http://poa-test.paas.newcapec.cn/oauth2/token
215 scopes:
216 "authz:v1:readRole": "读取角色"
217
218 responses:
219 'ErrorResponse400':
220 description: unexpected error
221 content:
222 application/json:
223 schema:
224 $ref: '#/components/schemas/ErrorResponse'
225
226 DefaultErrorResponse:
227 description: unexpected error
228 content:
229 application/json:
230 schema:
231 $ref: '#/components/schemas/ErrorResponse'
232
233 schemas:
234
235 # Error
236
237 ErrorResponse:
238 title: '异常响应'
239 required:
240 - code
241 - message
242 properties:
243 code:
244 title: 异常代码
245 type: integer
246 format: int32
247 default: -1
248 message:
249 title: 异常信息
250 type: string
251 default: "未知错误"
252
253 # Entity
254
255 BaseEntity:
256 title: 实体 - 基类
257 type: object
258 properties:
259 id:
260 title: ID
261 type: string
262 #companyId:
263 # title: 'Company ID, 固定 1'
264 # type: string
265 # default: '1'
266 #deleted:
267 # title: 是否删除
268 # type: boolean
269 # default: false
270 #addAccount:
271 # title: 创建人
272 # type: string
273 #addTime:
274 # title: 创建时间
275 # type: string
276 # format: date-time
277 #editAccount:
278 # title: 修改人
279 # type: string
280 #editTime:
281 # title: 修改时间
282 # type: string
283 # format: date-time
284 #deleteAccount:
285 # title: 删除人
286 # type: string
287 #deleteTime:
288 # title: 删除时间
289 # type: string
290 # format: date-time
291
292 User:
293 title: 实体 - 用户
294 allOf:
295 - $ref: '#/components/schemas/BaseEntity'
296 - type: object
297 title: 实体属性
298 properties:
299 username:
300 title: 代码
301 type: string
302 name:
303 title: 姓名
304 type: string
305
306 Role:
307 title: 实体 - 角色
308 allOf:
309 - $ref: '#/components/schemas/BaseEntity'
310 - type: object
311 title: 实体属性
312 properties:
313 code:
314 title: 代码
315 type: string
316 name:
317 title: 名称
318 type: string
319 description:
320 title: 描述
321 type: string
322 enabled:
323 title: 是否可用
324 type: boolean
325 externalId:
326 title: 扩展ID
327 type: string
328
329 # Request VO
330
331
332 # Response Data
333
334
335 # Response VO
336
337 AbstractApiResponse:
338 title: 响应
339 properties:
340 acknowleged:
341 title: 响应结果(废弃,请使用code)
342 type: boolean
343 default: true
344 code:
345 title: 响应代码
346 type: integer
347 format: int32
348 default: 0
349 message:
350 title: 响应信息
351 type: string
352 DefaultApiResponse:
353 allOf:
354 - $ref: '#/components/schemas/AbstractApiResponse'
355 - type: object
356 title: 响应数据
357 properties:
358 data:
359 title: 响应数据
360 type: object
361
362
363
364 ApplicationRolesResponse:
365 allOf:
366 - $ref: '#/components/schemas/DefaultApiResponse'
367 - type: object
368 title: 响应数据
369 properties:
370 data:
371 allOf:
372 - type: object
373 title: 数据
374 properties:
375 applicationId:
376 title: 应用标识
377 type: string
378 roles:
379 title: 角色数据
380 type: array
381 items:
382 $ref: '#/components/schemas/Role'
383
384
385 ApplicationRoleAccountsResponse:
386 allOf:
387 - $ref: '#/components/schemas/DefaultApiResponse'
388 - type: object
389 title: 响应数据
390 properties:
391 data:
392 allOf:
393 - type: object
394 title: 数据
395 properties:
396 applicationId:
397 title: 应用标识
398 type: string
399 rolecode:
400 title: 角色代码
401 type: string
402 accounts:
403 title: 用户帐号数据
404 type: array
405 items:
406 title: 用户的帐号ID
407 type: string
408
409
410 AccountApplicationRolesResponse:
411 allOf:
412 - $ref: '#/components/schemas/DefaultApiResponse'
413 - type: object
414 title: 响应数据
415 properties:
416 data:
417 allOf:
418 - type: object
419 title: 数据
420 properties:
421 username:
422 title: 用户名
423 type: string
424 applicationId:
425 title: 应用标识
426 type: string
427 roles:
428 title: 角色数据
429 type: array
430 items:
431 $ref: '#/components/schemas/Role'
432
433
434 ApplicationRolesAccountsResponse:
435 allOf:
436 - $ref: '#/components/schemas/DefaultApiResponse'
437 - type: object
438 title: 响应数据
439 properties:
440 data:
441 allOf:
442 - type: object
443 title: 数据
444 properties:
445 applicationId:
446 title: 应用标识
447 type: string
448 roleIds:
449 title: 角色IDs
450 type: array
451 items:
452 title: 角色ID
453 type: string
454 accounts:
455 title: 用户帐号数据
456 type: array
457 items:
458 title: 用户的帐号ID
459 type: string