-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect-profile-openapi.yml
675 lines (628 loc) · 22.1 KB
/
connect-profile-openapi.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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
openapi: 3.0.0
info:
contact:
email: [email protected]
description: 'The application stores user profile information, it is meant to be compliant with OpenID Connect specification'
version: 0.2.8
title: Connect Profile
tags:
- name: Connect Profile
description: An API for user OpenID Connect profile storage
- name: Connect Profile Admin
description: An admin API for user OpenID Connect profile storage
servers:
- url: 'http://localhost:21001'
paths:
/users/me/addresses:
get:
tags:
- Connect Profile
description: Retrieve all user's addresses based on the provided bearer token
operationId: getAddresses
security:
- bearer: []
responses:
'200':
$ref: '#/components/responses/GetAddressesSuccess'
'401':
$ref: '#/components/responses/EndUserUnauthorized'
'403':
$ref: '#/components/responses/MissingScope'
post:
tags:
- Connect Profile
description: Register user's address based on the provided bearer token
operationId: createAddress
security:
- bearer: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AddressPayload'
examples:
superman:
$ref: '#/components/examples/supermanAddressPayload'
responses:
'201':
$ref: '#/components/responses/CreateAddressSuccess'
'401':
$ref: '#/components/responses/EndUserUnauthorized'
'403':
$ref: '#/components/responses/MissingScope'
'422':
$ref: '#/components/responses/UnprocessableEntity'
/users/me/addresses/{id}/primary:
post:
tags:
- Connect Profile
description: Mark a user's address as primary
operationId: markUserAddressAsPrimary
security:
- bearer: []
parameters:
- name: id
in: path
description: the Address ID identifier of the requested Address
required: true
schema:
type: string
responses:
'201':
$ref: '#/components/responses/CreateAddressSuccess'
'401':
$ref: '#/components/responses/EndUserUnauthorized'
'403':
$ref: '#/components/responses/MissingScope'
'404':
$ref: '#/components/responses/AddressNotFound'
/users/me/addresses/{id}:
get:
tags:
- Connect Profile
description: Retrieve a user's address based on address ID
operationId: getAddress
security:
- bearer: []
parameters:
- name: id
in: path
description: the Address ID identifier of the requested Address
required: true
schema:
type: string
responses:
'200':
$ref: '#/components/responses/GetAddressSuccess'
'401':
$ref: '#/components/responses/EndUserUnauthorized'
'403':
$ref: '#/components/responses/MissingScope'
'404':
$ref: '#/components/responses/AddressNotFound'
patch:
tags:
- Connect Profile
description: Update a user's address based on the provided address ID
operationId: updateAddress
security:
- bearer: []
parameters:
- name: id
in: path
description: the Address ID identifier of the requested Address
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AddressData'
examples:
superman:
$ref: '#/components/examples/supermanAddressPayload'
responses:
'200':
$ref: '#/components/responses/PatchAddressSuccess'
'401':
$ref: '#/components/responses/EndUserUnauthorized'
'403':
$ref: '#/components/responses/MissingScope'
'404':
$ref: '#/components/responses/AddressNotFound'
'422':
$ref: '#/components/responses/UnprocessableEntity'
delete:
tags:
- Connect Profile
description: Delete a user's address based on address ID
operationId: deleteAddress
security:
- bearer: []
parameters:
- name: id
in: path
description: the Address ID identifier of the requested Address
required: true
schema:
type: string
responses:
'204':
description: The resource was deleted successfully.
'401':
$ref: '#/components/responses/EndUserUnauthorized'
'403':
$ref: '#/components/responses/MissingScope'
'404':
$ref: '#/components/responses/AddressNotFound'
/users/me/profile:
get:
tags:
- Connect Profile
description: Retrieve a user's profile based on the provided bearer token
operationId: getProfile
security:
- bearer: []
responses:
'200':
$ref: '#/components/responses/GetProfileSuccess'
'401':
$ref: '#/components/responses/EndUserUnauthorized'
'403':
$ref: '#/components/responses/MissingScope'
'404':
$ref: '#/components/responses/UserNotFound'
post:
tags:
- Connect Profile
description: Register a user's profile based on the provided bearer token
operationId: createProfile
security:
- bearer: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ProfileData'
examples:
superman:
$ref: '#/components/examples/supermanProfilePayload'
responses:
'201':
$ref: '#/components/responses/CreateProfileSuccess'
'401':
$ref: '#/components/responses/EndUserUnauthorized'
'403':
$ref: '#/components/responses/MissingScope'
'422':
$ref: '#/components/responses/UnprocessableEntity'
patch:
tags:
- Connect Profile
description: Update a user's profile based on the provided bearer token
operationId: patchProfile
security:
- bearer: []
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ProfileData'
examples:
superman:
$ref: '#/components/examples/supermanProfilePayload'
responses:
'200':
$ref: '#/components/responses/PatchProfileSuccess'
'401':
$ref: '#/components/responses/EndUserUnauthorized'
'403':
$ref: '#/components/responses/MissingScope'
'404':
$ref: '#/components/responses/UserNotFound'
'422':
$ref: '#/components/responses/UnprocessableEntity'
/users/profiles/{sub}:
delete:
tags:
- Connect Profile Admin
description: Delete a user profile based on the provided sub
operationId: deleteProfile
security:
- api_key: []
parameters:
- name: sub
in: path
description: the sub identifier of the requested User to delete
required: true
schema:
type: string
responses:
'204':
description: The resource was deleted successfully.
'401':
$ref: '#/components/responses/AdminUnauthorized'
'404':
$ref: '#/components/responses/UserNotFound'
/users/{sub}/addresses/{id}:
delete:
tags:
- Connect Profile Admin
description: Delete a user's address based on the provided sub and address id
operationId: deleteOneUserAddress
security:
- api_key: []
parameters:
- name: sub
in: path
description: the sub identifier of the requested User
required: true
schema:
type: string
- name: id
in: path
description: the address unique identifier of the address to delete
required: true
schema:
type: string
responses:
'204':
description: The resource was deleted successfully.
'401':
$ref: '#/components/responses/AdminUnauthorized'
'404':
$ref: '#/components/responses/AddressNotFound'
components:
securitySchemes:
bearer:
type: http
bearerFormat: JWT
scheme: bearer
api_key:
type: apiKey
name: Authorization
in: header
schemas:
AddressData:
type: object
description: An object representing the User's address
properties:
street_address:
type: string
description: 'Full street address of the End-User, which MAY include house number, street name, Post Office Box, and multi-line extended street address information. This field MAY contain multiple lines, separated by newlines. Newlines can be represented either as a carriage return/line feed pair ("\r\n") or as a single line feed character ("\n")'
street_address_2:
type: string
description: 'Optional additional component for the street address, e.g: floor number, door number, ...'
locality:
type: string
description: City or locality of the End-User.
region:
type: string
description: 'State, province, prefecture, or region of the End-User.'
postal_code:
type: string
description: Zip code or postal code of the End-User.
country:
type: string
description: Country name of the End-User.
kind:
type: string
description: 'The type of the End-User''s address, e.g: billing, delivery, ...'
AddressPayload:
allOf:
- $ref: '#/components/schemas/AddressData'
required:
- locality
- postal_code
- country
AddressesResponse:
type: array
items:
$ref: '#/components/schemas/AddressResponse'
AddressResponse:
allOf:
- $ref: '#/components/schemas/AddressData'
- type: object
properties:
primary:
type: boolean
description: Set to true means this is the user's primary address.
updated_at:
type: integer
description: Time the End-User's information was last updated. Its value is a JSON number representing the number of seconds from 1970-01-01T0:0:0Z as measured in UTC until the date/time.
id:
type: string
description: Address's unique identifier.
ProfileData:
type: object
properties:
name:
type: string
description: 'End-User''s full name in displayable form including all name parts, possibly including titles and suffixes, ordered according to the End-User''s preferences.'
family_name:
type: string
description: 'Surname(s) or last name(s) of the End-User. Note that in some cultures, people can have multiple family names or no family name; all can be present, with the names being separated by space characters.'
given_name:
type: string
description: 'Given name(s) or first name(s) of the End-User. Note that in some cultures, people can have multiple given names; all can be present, with the names being separated by space characters.'
middle_name:
type: string
description: 'Middle name(s) of the End-User. Note that in some cultures, people can have multiple middle names; all can be present, with the names being separated by space characters. Also note that in some cultures, middle names are not used.'
nickname:
type: string
description: 'Casual name of the End-User that may or may not be the same as the given_name. For instance, a nickname value of Mike might be returned alongside a given_name value of Michael.'
preferred_username:
type: string
description: 'Shorthand name by which the End-User wishes to be referred to by the Provider, such as janedoe or j.doe. This value MAY be any valid JSON string including special characters such as @, /, or whitespace. The Provider MUST NOT rely upon this value being unique.'
profile:
type: string
description: URL of the End-User's profile page. The contents of this Web page SHOULD be about the End-User.
picture:
type: string
description: 'URL of the End-User''s profile picture. This URL MUST refer to an image file (for example, a PNG, JPEG, or GIF image file), rather than to a Web page containing an image. Note that this URL SHOULD specifically reference a profile photo of the End-User suitable for displaying when describing the End-User, rather than an arbitrary photo taken by the End-User.'
website:
type: string
description: URL of the End-User's Web page or blog. This Web page SHOULD contain information published by the End-User or an organization that the End-User is affiliated with.
gender:
type: string
description: End-User's gender. Values defined by this specification are female and male. Other values MAY be used when neither of the defined values are applicable.
birthdate:
type: string
description: 'End-User''s birthday, represented as an ISO 8601:2004 [ISO8601‑2004] YYYY-MM-DD format. The year MAY be 0000, indicating that it is omitted. To represent only the year, YYYY format is allowed. Note that depending on the underlying platform''s date related function, providing just year can result in varying month and day, so the implementers need to take this factor into account to correctly process the dates.'
zoneinfo:
type: string
description: 'String from zoneinfo [zoneinfo] time zone database representing the End-User''s time zone. For example, Europe/Paris or America/Los_Angeles.'
locale:
type: string
description: End-User's locale.
ProfileResponse:
allOf:
- $ref: '#/components/schemas/ProfileData'
- type: object
properties:
sub:
type: string
description: Identifier for the End-User at the Issuer.
updated_at:
type: integer
description: 'Time the End-User''s information was last updated. Its value is a JSON number representing the number of seconds from 1970-01-01T0:0:0Z as measured in UTC until the date/time.'
responses:
# ERRORS
AdminUnauthorized:
description: Unauthorized request
content:
application/json:
schema:
type: object
properties:
error:
type: string
default: Without a valid API key you are not allowed to access this endpoint
EndUserUnauthorized:
description: Unauthorized request
content:
application/json:
schema:
type: object
properties:
error:
type: string
default: Without a valid bearer token you are not allowed to access this endpoint
MissingScope:
description: The endpoint needs some specific scopes.
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: an english message describing the error
enum:
- The given scopes don't allow you to perform this action
errors:
type: object
description: an object representing invalid scopes
properties:
address:
type: string
default: Must be present
profile:
type: string
default: Must be present
UnprocessableEntity:
description: Invalid input parameters
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: an english message describing the error
enum:
- Invalid User data
errors:
type: object
description: an object representing invalid fields
properties:
sub:
type: string
default: can't be blank
birthdate:
type: string
default: Must be an ISO8601 date
AddressNotFound:
description: Address Not Found
content:
application/json:
schema:
type: object
properties:
error:
type: string
default: Address not found
# USERS
UserNotFound:
description: User Not Found
content:
application/json:
schema:
type: object
properties:
error:
type: string
default: User not found
# ADDRESSES
GetAddressesSuccess:
description: Successful Get Addresses Request
content:
application/json:
schema:
$ref: '#/components/schemas/AddressesResponse'
examples:
'Superman addresses':
$ref: '#/components/examples/supermanAddresses'
GetAddressSuccess:
description: Successful Get Address Request
content:
application/json:
schema:
$ref: '#/components/schemas/AddressResponse'
examples:
'Superman addresses':
$ref: '#/components/examples/supermanPrimaryAddress'
CreateAddressSuccess:
description: A successful User Address creation response
content:
application/json:
schema:
$ref: '#/components/schemas/AddressResponse'
examples:
Superman:
$ref: '#/components/examples/supermanPrimaryAddress'
MarkAddressAsPrimarySuccess:
description: A successful mark User Address as primary response
content:
application/json:
schema:
$ref: '#/components/schemas/AddressResponse'
examples:
"Superman's primary address":
$ref: '#/components/examples/supermanPrimaryAddress'
PatchAddressSuccess:
description: Successful Patch User's Address Request
content:
application/json:
schema:
$ref: '#/components/schemas/AddressResponse'
examples:
superman:
$ref: '#/components/examples/supermanPrimaryAddress'
# PROFILE
GetProfileSuccess:
description: Successful Get Profile Request
content:
application/json:
schema:
$ref: '#/components/schemas/ProfileResponse'
examples:
"Superman's profile":
$ref: '#/components/examples/supermanProfile'
CreateProfileSuccess:
description: A successful User Profile creation response
content:
application/json:
schema:
$ref: '#/components/schemas/ProfileResponse'
examples:
superman:
$ref: '#/components/examples/supermanProfile'
PatchProfileSuccess:
description: Successful Patch User's Profile Request
content:
application/json:
schema:
$ref: '#/components/schemas/ProfileResponse'
examples:
superman:
$ref: '#/components/examples/supermanProfile'
examples:
supermanAddressPayload:
value:
street_address: 344 Clinton St.
street_address_2: 'Apt. #3B'
locality: Metropolis
postal_code: '62960'
region: Delaware
country: United States of America
kind: delivery
supermanPrimaryAddress:
value:
id: CD333E28-4647-48E3-A036-DAFA9D8ED1BB
street_address: 344 Clinton St.
street_address_2: 'Apt. #3B'
locality: Metropolis
postal_code: '62960'
region: Delaware
country: United States of America
primary: true
kind: delivery
updated_at: 1570550562
supermanAddresses:
value:
- id: CD333E28-4647-48E3-A036-DAFA9D8ED1BB
street_address: 344 Clinton St.
street_address_2: 'Apt. #3B'
locality: Metropolis
postal_code: '62960'
region: Delaware
country: United States of America
primary: true
kind: delivery
updated_at: 1570550562
- id: 83FE11B6-E035-443C-9DB1-A4236E314176
street_address: '355, 1000 Broadway'
locality: Metropolis
postal_code: '62960'
region: Delaware
country: United States of America
primary: false
kind: work
updated_at: 1570550562
supermanProfilePayload:
value:
name: Clark Kent
family_name: Kent
given_name: Kal-El
middle_name: Joseph
nickname: Superman
preferred_username: Clark
profile: 'https://www.dccomics.com/characters/superman'
picture: 'https://source.unsplash.com/random'
website: 'https://superman.com'
gender: male
birthdate: '1938-04-01'
zoneinfo: America/Los_Angeles
locale: EN-us
supermanProfile:
value:
name: Clark Kent
family_name: Kent
given_name: Kal-El
middle_name: Joseph
nickname: Superman
preferred_username: Clark
profile: 'https://www.dccomics.com/characters/superman'
picture: 'https://source.unsplash.com/random'
website: 'https://superman.com'
gender: male
birthdate: '1938-04-01'
zoneinfo: America/Los_Angeles
locale: EN-us
updated_at: 1570550562