-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathopenAPI.yaml
More file actions
3361 lines (3257 loc) · 102 KB
/
openAPI.yaml
File metadata and controls
3361 lines (3257 loc) · 102 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
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
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.0.3
info:
title: DeDi API
description: |
DeDi (Decentralized Directory) API provides comprehensive functionality for managing
namespaces, registries, and records in a decentralized directory system.
## Authentication
The API supports dual authentication methods:
- **API Key Authentication**: Bearer token in Authorization header (recommended for production)
- **Cookie Authentication**: Token cookie for browser integration
All authentication endpoints now support password-based authentication with robust security requirements.
## Base Concepts
- **Namespace**: Top-level organization unit for grouping related registries
- **Registry**: Schema-defined container for records within a namespace
- **Record**: Individual data entries conforming to registry schema
## Key Features
- **Password-based Authentication**: Secure login with enforced password complexity
- **Domain Verification**: Verify ownership of domains for namespace binding
- **Bulk Operations**: CSV import/export for large-scale data management
- **Real-time Notifications**: Watch system for monitoring changes via webhooks
- **Delegation Management**: Fine-grained access control and user permissions
- **Version Control**: Complete history tracking for all resources
- **Advanced Search**: Powerful search with nested field support
- **State Management**: Comprehensive lifecycle management for registries and records
## Rate Limiting
Standard rate limits apply to all endpoints. Contact support for enterprise limits.
## Production Readiness
This API specification is production-grade and includes:
- Comprehensive error handling with detailed error codes
- Extensive documentation with examples
- Security best practices implementation
- Scalable architecture design
- Full CRUD operations for all resources
version: 2.0.0
contact:
name: DeDi Support
url: https://docs.dedi.global
license:
name: MIT
servers:
- url: https://api.dedi.global
description: Production server
- url: https://staging-api.dedi.global
description: Staging server
security:
- BearerAuth: []
- CookieAuth: []
paths:
# Authentication endpoints
/dedi/register:
post:
tags:
- Authentication
summary: Register or login user
description: |
Universal endpoint for user registration and login. Use 'action' parameter to specify operation.
- For registration: email, name, password, and action='register' required
- For login: email, password, and action='login' required
**Password Requirements:**
- Minimum 6 characters
- Must include at least one special character (@$!%*?&)
operationId: registerLogin
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
- action
- password
properties:
email:
type: string
format: email
example: user@example.com
name:
type: string
example: John Doe
description: Required for registration, optional for login
action:
type: string
enum: [register, login]
example: register
password:
type: string
minLength: 6
pattern: '^(?=.*[@$!%*?&]).*$'
description: Password with at least 6 characters and one special character (@$!%*?&)
example: Test@123
examples:
register:
summary: User registration
value:
email: user@example.com
name: John Doe
action: register
password: Test@123
login:
summary: User login
value:
email: user@example.com
action: login
password: Test@123
responses:
'200':
description: Success - check email for verification link
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
'400':
description: Bad request - missing or invalid parameters
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/verify-email:
get:
tags:
- Authentication
summary: Verify email with magic link token
description: Verifies user email using the token from the magic link sent via email
operationId: verifyEmail
security: []
parameters:
- name: token
in: query
required: true
schema:
type: string
description: Email verification token from magic link
example: abc123xyz456
responses:
'200':
description: Email verified successfully
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: success
data:
type: object
properties:
refresh_token:
type: string
description: JWT refresh token for session management
'400':
description: Invalid or expired token
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Token not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/auth/me:
get:
tags:
- Authentication
summary: Get current authenticated user
description: Retrieves information about the currently authenticated user
operationId: getCurrentUser
responses:
'200':
description: User information retrieved successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: User retrieved successfully
data:
$ref: '#/components/schemas/User'
'401':
description: Unauthorized - invalid or missing token
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/token/refresh:
post:
tags:
- Authentication
summary: Refresh authentication token
description: Refreshes the authentication token using a valid refresh token
operationId: refreshToken
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- refresh_token
properties:
refresh_token:
type: string
description: Valid refresh token
responses:
'200':
description: Token refreshed successfully
content:
application/json:
schema:
type: object
properties:
access_token:
type: string
refresh_token:
type: string
'401':
description: Invalid or expired refresh token
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/logout:
post:
tags:
- Authentication
summary: Logout user
description: Invalidates the current session and authentication tokens
operationId: logout
responses:
'200':
description: Logged out successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/reset-password:
post:
tags:
- Authentication
summary: Reset password (authenticated user)
description: |
Reset password for the currently authenticated user.
**Password Requirements:**
- Minimum 6 characters
- Must include at least one special character (@$!%*?&)
operationId: resetPassword
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- new_password
- confirm_password
properties:
new_password:
type: string
minLength: 6
pattern: '^(?=.*[@$!%*?&]).*$'
description: New password meeting requirements
confirm_password:
type: string
minLength: 6
pattern: '^(?=.*[@$!%*?&]).*$'
description: Must match new_password
responses:
'200':
description: Password reset successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
'400':
description: Invalid password or missing parameters
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Unauthorized or incorrect old password
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/forgot-password:
post:
tags:
- Authentication
summary: Forgot password
description: |
Send a password reset link to the user's email address.
**Process:**
1. Submit email address
2. Check email for reset link
3. Use reset link to access password reset form
4. Set new password via reset-password/confirm endpoint
operationId: forgotPassword
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- email
properties:
email:
type: string
format: email
description: Email address of the account
example: user@example.com
responses:
'200':
description: Reset link sent to email
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
'400':
description: Invalid email format
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Email not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/reset-password/confirm:
post:
tags:
- Authentication
summary: Confirm password reset
description: |
Confirm password reset using the token received via email.
**Password Requirements:**
- Minimum 6 characters
- Must include at least one special character (@$!%*?&)
**Security:** Reset tokens expire after 15 minutes by default
operationId: confirmPasswordReset
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- token
- new_password
properties:
token:
type: string
description: Reset token from email link
new_password:
type: string
minLength: 6
pattern: '^(?=.*[@$!%*?&]).*$'
description: New password meeting requirements
example: NewPass@123
responses:
'200':
description: Password reset confirmed successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
'400':
description: Invalid or expired token, or invalid password
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/resend-magic-link:
post:
tags:
- Authentication
summary: Resend magic link
description: |
Resend email verification link for users who didn't receive or lost their verification email.
**Prerequisites:**
- User must already be registered
- Account must exist in the system
**Note:** This endpoint requires the user's existing credentials to prevent abuse
operationId: resendMagicLink
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- action
- email
- name
- password
properties:
action:
type: string
enum: [register]
description: Should be 'register'
example: register
email:
type: string
format: email
description: Email address of the account
example: user@example.com
name:
type: string
description: User's name
example: John Doe
password:
type: string
description: User's password
example: Test@123
responses:
'200':
description: Magic link resent successfully
content:
application/json:
schema:
$ref: '#/components/schemas/SuccessResponse'
'400':
description: Invalid credentials or account not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/get-api-key:
get:
tags:
- Authentication
summary: Generate API key
description: Generates a new API key for authenticated user for programmatic access
operationId: getApiKey
responses:
'200':
description: API key generated successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: API key generated
data:
type: object
properties:
api_key:
type: string
description: Generated API key for Bearer authentication
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
# Publishing endpoints
/dedi/create-namespace:
post:
tags:
- Publishing
summary: Create a new namespace
description: |
Creates a new namespace to organize and group related registries.
Namespaces provide top-level organization for data segregation.
operationId: createNamespace
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- name
- description
properties:
name:
type: string
description: Unique namespace name
example: my-company
description:
type: string
description: Description of the namespace purpose
example: Company employee registry namespace
meta:
type: object
description: Additional metadata
example: {}
version_count:
type: number
description: Version number
example: 1
responses:
'201':
description: Namespace created successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Namespace created successfully
data:
$ref: '#/components/schemas/Namespace'
'400':
description: Bad request - invalid parameters
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'409':
description: Conflict - namespace name already exists
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/{namespace}/create-registry:
post:
tags:
- Publishing
summary: Create a new registry
description: |
Creates a new registry within a namespace with a defined schema for records.
Registries define the structure and validation rules for records.
operationId: createRegistry
parameters:
- name: namespace
in: path
required: true
schema:
type: string
description: Namespace ID or domain name
example: my-company
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- name
- description
- schema
properties:
name:
type: string
description: Unique registry name within namespace
example: employees
description:
type: string
description: Registry description
example: Employee records registry
schema:
type: object
description: JSON Schema for record validation
example:
type: object
required: [name, email]
properties:
name:
type: string
email:
type: string
format: email
tag:
type: string
enum: [custom, membership, public_key, revoke]
description: Schema tag for categorization
example: custom
default: custom
meta:
type: object
description: Additional metadata
example: {}
responses:
'201':
description: Registry created successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Registry created successfully
data:
$ref: '#/components/schemas/Registry'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'403':
description: Forbidden - insufficient permissions
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Namespace not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/{namespace}/{registry_name}/save-draft:
post:
tags:
- Publishing
summary: Save record as draft
description: |
Saves a record as a draft without publishing. Drafts can be edited and later published.
operationId: saveRecordAsDraft
parameters:
- name: namespace
in: path
required: true
schema:
type: string
description: Namespace ID or domain name
- name: registry_name
in: path
required: true
schema:
type: string
description: Registry name
- name: publish
in: query
schema:
type: boolean
description: Set to true to save and publish immediately
example: true
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- name
- details
properties:
name:
type: string
description: Unique record name within registry
example: john-doe
description:
type: string
description: Record description
example: John Doe employee record
details:
type: object
description: Record data conforming to registry schema
example:
name: John Doe
email: john.doe@company.com
department: Engineering
meta:
type: object
description: Additional metadata
example: {}
valid_till:
type: string
format: date-time
description: Expiration date in ISO format (optional)
example: 2024-12-31T23:59:59Z
ttl:
type: integer
description: Time to live in seconds
example: 86400
responses:
'201':
description: Draft saved successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Draft saved successfully
data:
$ref: '#/components/schemas/Record'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Namespace or registry not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/{namespace}/{registry_name}/publish-record:
post:
tags:
- Publishing
summary: Publish record
description: |
Publishes a record directly or promotes a draft to live state.
Published records become available for lookup and queries.
operationId: publishRecord
parameters:
- name: namespace
in: path
required: true
schema:
type: string
description: Namespace ID or domain name
- name: registry_name
in: path
required: true
schema:
type: string
description: Registry name
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- name
- details
properties:
name:
type: string
description: Unique record name within registry
description:
type: string
description: Record description
details:
type: object
description: Record data conforming to registry schema
meta:
type: object
description: Additional metadata
valid_till:
type: string
format: date-time
description: Expiration date in ISO format (optional)
example: 2024-12-31T23:59:59Z
ttl:
type: integer
description: Time to live in seconds
responses:
'201':
description: Record published successfully
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Record published successfully
data:
$ref: '#/components/schemas/Record'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/{namespace}/{registry_name}/bulk-upload:
post:
tags:
- Publishing
summary: Bulk upload records
description: |
Uploads multiple records in a single operation. Returns a job ID for tracking progress.
operationId: bulkUploadRecords
parameters:
- name: namespace
in: path
required: true
schema:
type: string
description: Namespace ID or domain name
- name: registry_name
in: path
required: true
schema:
type: string
description: Registry name
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required:
- file
properties:
file:
type: string
format: binary
description: CSV file containing record data
responses:
'202':
description: Bulk upload job started
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Bulk upload job started
data:
type: object
properties:
job_id:
type: string
description: Job ID for tracking progress
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/{namespace}/{registry_name}/export-records-as-csv:
get:
tags:
- Publishing
summary: Export records as CSV
description: |
Export all records from a registry as a CSV file for analysis, backup, or migration purposes.
**CSV Format:**
- Headers match registry schema fields
- One row per record
- Includes record metadata (ID, timestamps, state)
- Nested objects flattened with dot notation
**Performance:**
- Optimized for large datasets
- Streaming response for memory efficiency
- Suitable for registries with thousands of records
**Access Control:**
- Requires registry read permissions
- User must be authorized for the registry
operationId: exportRecordsAsCsv
parameters:
- name: namespace
in: path
required: true
schema:
type: string
description: Namespace ID or domain
- name: registry_name
in: path
required: true
schema:
type: string
description: Registry name to export records from
responses:
'200':
description: CSV file with registry records
content:
text/csv:
schema:
type: string
format: binary
examples:
csv_export:
summary: Sample CSV export
value: |
record_id,record_name,description,email,name,created_at,state
rec_123,john-doe,Employee record,john@company.com,John Doe,2024-01-15T10:30:00Z,live
rec_124,jane-smith,Employee record,jane@company.com,Jane Smith,2024-01-16T14:20:00Z,live
'401':
description: Unauthorized
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'403':
description: Insufficient permissions
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
'404':
description: Namespace or registry not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
/dedi/jobs/{job_id}:
get:
tags:
- Publishing
summary: Get job status
description: Retrieves the status and progress of a bulk upload job
operationId: getJobStatus
parameters:
- name: job_id
in: path
required: true
schema:
type: string
description: Job ID from bulk upload
responses:
'200':
description: Job status retrieved
content:
application/json:
schema:
type: object
properties:
message:
type: string
example: Job status retrieved
data: