-
Notifications
You must be signed in to change notification settings - Fork 2
/
swagger.yml
934 lines (925 loc) · 25.1 KB
/
swagger.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
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
openapi: "3.0.0"
info:
version: 1.0.0
description: This is REST endpoints API documentation for E-invoice project.
title: E-invoice API
servers:
- description: Dev
url: https://dev.api.einvoice.mfsr.sk
tags:
- name: Auth
- name: Users
- name: Invoices
- name: Drafts
paths:
/login:
get:
tags:
- Auth
summary: Authenticate user with ÚPVS (slovensko.sk) token
security:
- upvsOboTokenAuth: []
responses:
'200':
$ref: '#/components/responses/Login'
'401':
$ref: '#/components/responses/Error'
'403':
$ref: '#/components/responses/Error'
'424':
$ref: '#/components/responses/Error'
/logout:
get:
tags:
- Auth
summary: Logout user from e-invoice
security:
- sessionAuth: []
responses:
'200':
$ref: '#/components/responses/Logout'
'401':
$ref: '#/components/responses/Error'
/upvs/logout:
get:
tags:
- Auth
summary: Redirect to ÚPVS (slovensko.sk) logout
description: |
Redirect to ÚPVS and invalidate OBO token.
If OBO token is already invalid redirect to ÚPVS callback directly
parameters:
- name: token
in: query
description: OBO token
schema:
type: string
required: true
- name: callback
in: query
description: |
Callback URL, to which user will be redirected once logout is successful.
Callback URL has to be same as one of the addresses set at the component API level,
or it has to be an extension of one of these addresses.
schema:
type: string
required: true
responses:
'302':
description: Redirect user to ÚPVS logout
'401':
$ref: '#/components/responses/Error'
/users/{userId}:
parameters:
- name: userId
in: path
description: ID of user to be affected
required: true
schema:
type: integer
get:
tags:
- Users
summary: Get info about requested user
security:
- sessionAuth: []
- apiKeyAuth: []
responses:
'200':
description: User data
content:
application/json:
schema:
$ref: '#/components/schemas/UserInfo'
'401':
$ref: '#/components/responses/Error'
patch:
tags:
- Users
summary: Update user info
security:
- sessionAuth: []
- apiKeyAuth: []
requestBody:
$ref: '#/components/requestBodies/PatchUser'
responses:
'200':
description: Updated user info
content:
application/json:
schema:
$ref: '#/components/schemas/UserInfo'
'400':
$ref: '#/components/responses/Error'
'401':
$ref: '#/components/responses/Error'
/users/{userId}/substitutes:
parameters:
- name: userId
in: path
description: ID of user to be affected
required: true
schema:
type: integer
post:
tags:
- Users
summary: Add substitute users
description: Add rights for particular users to create invoices on your behalf
security:
- sessionAuth: []
- apiKeyAuth: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SubstituteIds'
responses:
'200':
description: List of substitute Ids that were successfully added
content:
application/json:
schema:
$ref: '#/components/schemas/SubstituteIds'
'400':
$ref: '#/components/responses/Error'
delete:
tags:
- Users
summary: Remove substitute users
description: Revoke rights for particular users to create invoices on your behalf
security:
- sessionAuth: []
- apiKeyAuth: []
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SubstituteIds'
responses:
'200':
description: List of substitute Ids that were successfully removed
content:
application/json:
schema:
$ref: '#/components/schemas/SubstituteIds'
'400':
$ref: '#/components/responses/Error'
get:
tags:
- Users
summary: Get substitute users
description: Get list of users that can create invoices on your behalf
security:
- sessionAuth: []
- apiKeyAuth: []
responses:
'200':
description: List of substitute user Ids of requested user
content:
application/json:
schema:
$ref: '#/components/schemas/SubstituteIds'
/users/{userId}/organizations:
get:
tags:
- Users
summary: Get substituted organizations
description: Get list of IČOs that requested user can create invoices on behalf of
parameters:
- name: userId
in: path
description: User ID
required: true
schema:
type: integer
security:
- sessionAuth: []
- apiKeyAuth: []
responses:
'200':
description: List of substituted organizations for requested user
content:
application/json:
schema:
$ref: '#/components/schemas/SubstitutedOrganizations'
/users/{userId}/invoices:
get:
tags:
- Users
summary: Get all invoices requested user can view
parameters:
- name: userId
in: path
description: Get invoices of user with this user ID
required: true
schema:
type: integer
- $ref: '#/components/parameters/InvoiceFormat'
- $ref: '#/components/parameters/StartId'
- $ref: '#/components/parameters/Order'
- $ref: '#/components/parameters/Limit'
- $ref: '#/components/parameters/TestInvoice'
- $ref: '#/components/parameters/AmountFrom'
- $ref: '#/components/parameters/AmountTo'
- $ref: '#/components/parameters/AmountCurrency'
- $ref: '#/components/parameters/AmountWithoutVatFrom'
- $ref: '#/components/parameters/AmountWithoutVatTo'
- $ref: '#/components/parameters/AmountWithoutVatCurrency'
- $ref: '#/components/parameters/IssueDateFrom'
- $ref: '#/components/parameters/IssueDateTo'
- $ref: '#/components/parameters/UploadTimeFrom'
- $ref: '#/components/parameters/UploadTimeTo'
- $ref: '#/components/parameters/CustomerName'
- $ref: '#/components/parameters/SupplierName'
- $ref: '#/components/parameters/CustomerIco'
- $ref: '#/components/parameters/SupplierIco'
security:
- sessionAuth: []
- apiKeyAuth: []
responses:
'200':
description: List of user invoices
content:
application/json:
schema:
$ref: '#/components/schemas/Invoices'
/invoices:
get:
tags:
- Invoices
summary: Get list of metadata of public invoices
parameters:
- $ref: '#/components/parameters/InvoiceFormat'
- $ref: '#/components/parameters/StartId'
- $ref: '#/components/parameters/Order'
- $ref: '#/components/parameters/Limit'
- $ref: '#/components/parameters/TestInvoice'
- $ref: '#/components/parameters/AmountFrom'
- $ref: '#/components/parameters/AmountTo'
- $ref: '#/components/parameters/AmountCurrency'
- $ref: '#/components/parameters/AmountWithoutVatFrom'
- $ref: '#/components/parameters/AmountWithoutVatTo'
- $ref: '#/components/parameters/AmountWithoutVatCurrency'
- $ref: '#/components/parameters/IssueDateFrom'
- $ref: '#/components/parameters/IssueDateTo'
- $ref: '#/components/parameters/UploadTimeFrom'
- $ref: '#/components/parameters/UploadTimeTo'
- $ref: '#/components/parameters/CustomerName'
- $ref: '#/components/parameters/SupplierName'
- $ref: '#/components/parameters/CustomerIco'
- $ref: '#/components/parameters/SupplierIco'
responses:
'200':
description: Successfull response
content:
application/json:
schema:
$ref: '#/components/schemas/Invoices'
post:
security:
- sessionAuth: []
- apiKeyAuth: []
tags:
- Invoices
summary: Create invoice
requestBody:
description: "UBL2.1 or D16B invoice"
content:
application/xml:
schema:
type: object
xml:
name: Invoice
responses:
'201':
description: Invoice created
content:
application/json:
schema:
$ref: '#/components/schemas/Invoice'
'400':
$ref: '#/components/responses/Error'
'403':
$ref: '#/components/responses/Error'
'424':
$ref: '#/components/responses/Error'
/invoices/test:
post:
security:
- sessionAuth: []
- apiKeyAuth: []
tags:
- Invoices
summary: Create test invoice
requestBody:
description: "UBL2.1 or D16B invoice"
content:
application/xml:
schema:
type: object
xml:
name: Invoice
responses:
'201':
description: Test invoice created
content:
application/json:
schema:
$ref: '#/components/schemas/Invoice'
'400':
$ref: '#/components/responses/Error'
'403':
$ref: '#/components/responses/Error'
'429':
$ref: '#/components/responses/Error'
/invoices/visualization:
post:
tags:
- Invoices
summary: Get visualization of sent invoice
requestBody:
description: "UBL2.1 or D16B invoice"
content:
application/xml:
schema:
type: object
xml:
name: Invoice
responses:
'200':
description: Successful response
content:
application/zip:
schema:
type: string
format: binary
/invoices/{invoiceId}:
get:
tags:
- Invoices
summary: Get invoice meta data
parameters:
- name: invoiceId
in: path
description: Invoice ID
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Successfull response
content:
application/json:
schema:
$ref: '#/components/schemas/Invoice'
'403':
$ref: '#/components/responses/Error'
'404':
$ref: '#/components/responses/Error'
/invoices/{invoiceId}/detail:
get:
tags:
- Invoices
summary: Get invoice content
parameters:
- name: invoiceId
in: path
description: Invoice ID
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Successful response
content:
application/xml:
schema:
$ref: '#/components/schemas/Invoice'
'403':
$ref: '#/components/responses/Error'
'404':
$ref: '#/components/responses/Error'
/invoices/{invoiceId}/visualization:
get:
tags:
- Invoices
summary: Get invoice visualization
parameters:
- name: invoiceId
in: path
description: Invoice ID
required: true
schema:
type: string
format: uuid
responses:
'200':
description: Successful response
content:
application/zip:
schema:
type: string
format: binary
'403':
$ref: '#/components/responses/Error'
'404':
$ref: '#/components/responses/Error'
/drafts:
get:
tags:
- Drafts
security:
- sessionAuth: []
summary: Get my invoice drafts
responses:
'200':
description: List of draft metadata
content:
application/json:
schema:
$ref: '#/components/schemas/Drafts'
'403':
$ref: '#/components/responses/Error'
post:
tags:
- Drafts
security:
- sessionAuth: []
summary: Create my invoice draft
requestBody:
description: Draft of invoice form
content:
application/json:
schema:
type: object
properties:
name:
type: string
data:
type: object
properties:
type:
type: string
enum:
- invoice
- creditNote
data:
type: object
description: Redux state of invoice form
responses:
'201':
description: Draft created
content:
application/json:
schema:
$ref: '#/components/schemas/Draft'
'400':
$ref: '#/components/responses/Error'
'403':
$ref: '#/components/responses/Error'
'429':
$ref: '#/components/responses/Error'
/drafts/{draftId}:
get:
tags:
- Drafts
security:
- sessionAuth: []
summary: Get draft content
parameters:
- $ref: '#/components/parameters/DraftId'
responses:
'200':
description: Draft
content:
application/json:
schema:
type: object
properties:
type:
type: string
enum:
- invoice
- creditNote
data:
type: object
description: Redux state of invoice form
patch:
tags:
- Drafts
security:
- sessionAuth: []
summary: Update draft
requestBody:
description: Draft of invoice form
content:
application/json:
schema:
type: object
properties:
name:
type: string
nullable: true
data:
type: object
nullable: true
properties:
type:
type: string
enum:
- invoice
- creditNote
data:
type: object
description: Redux state of invoice form
parameters:
- $ref: '#/components/parameters/DraftId'
responses:
'200':
description: Updated draft
content:
application/json:
schema:
$ref: '#/components/schemas/PatchedDraft'
delete:
tags:
- Drafts
security:
- sessionAuth: []
summary: Delete draft
parameters:
- $ref: '#/components/parameters/DraftId'
responses:
'200':
description: ID of deleted draft
content:
application/json:
schema:
type: object
properties:
id:
type: string
format: uuid
'403':
$ref: '#/components/responses/Error'
components:
securitySchemes:
upvsOboTokenAuth:
description: OBO token received from ÚPVS (slovensko.sk)
type: http
scheme: bearer
bearerFormat: JWT
sessionAuth:
description: Token received in response of login request
type: http
scheme: bearer
apiKeyAuth:
description: |
JWT token satisfying:
- encoded by RS256 algorithm
- signed by your private key (paired with public key you set in your account)
- `sub` claim set to your user Id as integer
- `exp` claim set to current Unix timestamp + 10 minutes
- `jti` claim set to random string unique during 15 minutes
Example of `header` segment:
{
"alg": "RS256",
"typ": "JWT"
}
Example of `payload` segment:
{
"sub": 1,
"exp": 1607590024,
"jti": "4dee8618-abbe-4dc3-83ba-e984d1396f9f"
}
Notes:
- `jti` value should follow regular expression `/\A[0-9a-z\-_]{32,256}\z/i`
- same `jti` value cannot be reused in 15 minute timeframe
- server considers `exp` valid if it fits in time interval `(current Unix; current Unix + 10 minutes)`
type: apiKey
in: header
name: X-API-Key
schemas:
UserInfo:
type: object
properties:
id:
type: integer
example: 8498081
upvsUri:
type: string
example: rc://sk/8314451298_tisici_janko
name:
type: string
serviceAccountPublicKey:
type: string
createdAt:
type: string
format: date-time
Invoices:
type: object
properties:
nextId:
type: string
format: uuid
nullable: true
invoices:
type: array
items:
$ref: '#/components/schemas/Invoice'
InvoiceFormat:
type: string
enum:
- ubl2.1
- d16b
Invoice:
type: object
properties:
id:
type: string
format: uuid
sender:
type: string
example: SubjectA
receiver:
type: string
example: SubjectB
format:
$ref: '#/components/schemas/InvoiceFormat'
price:
type: integer
example: 100
supplierIco:
type: string
example: '11190993'
customerIco:
type: string
example: '11190993'
createdAt:
type: string
format: date-time
issueDate:
type: string
format: date
createdBy:
type: integer
test:
type: boolean
description: True if invoice is just for test purposes
notificationsSent:
type: boolean
description: True if involved parties were notified
SubstituteIds:
type: array
items:
type: integer
description: Substitute ID
SubstitutedOrganizations:
type: array
items:
type: integer
description: Organization ID (IČO)
Drafts:
type: array
items:
$ref: '#/components/schemas/Draft'
Draft:
type: object
properties:
name:
type: string
id:
type: string
format: uuid
createdAt:
type: string
format: date-time
data:
type: object
properties:
type:
type: string
enum:
- invoice
- creditNote
data:
type: object
description: Redux state of invoice form
PatchedDraft:
type: object
properties:
name:
type: string
id:
type: string
format: uuid
createdAt:
type: string
format: date-time
data:
type: object
nullable: true
properties:
type:
type: string
enum:
- invoice
- creditNote
data:
type: object
description: Redux state of invoice form
Error:
type: object
properties:
error:
type: string
detail:
type: string
required:
- error
parameters:
Limit:
name: limit
in: query
description: Limit number of entities returned
schema:
type: integer
minimum: 1
TestInvoice:
name: test
in: query
description: If flag turned on, test invoices are considered as well
schema:
type: boolean
Order:
name: order
in: query
description: |
Order of returned entities. If not provided order is not guaranteed.
- `asc` - entitites are returned from the oldest to the newest
- `desc` - entities are returned from the newest to the oldest
schema:
type: string
enum:
- asc
- desc
StartId:
name: startId
in: query
description: Entity id where service start search
schema:
type: string
format: uuid
InvoiceFormat:
name: format
in: query
description: Filter invoices by format
schema:
type: array
items:
$ref: '#/components/schemas/InvoiceFormat'
AmountFrom:
name: amountFrom
in: query
description: Select invoices with amount not lesser than this value
schema:
type: number
AmountTo:
name: amountTo
in: query
description: Select invoices with amount not greater than this value
schema:
type: number
AmountCurrency:
name: amountCurrency
in: query
description: Filter invoices by amount currency
schema:
type: string
AmountWithoutVatFrom:
name: amountWithoutVatFrom
in: query
description: Select invoices with amount without VAT not lesser than this value
schema:
type: number
AmountWithoutVatTo:
name: amountWithoutVatTo
in: query
description: Select invoices with amount without VAT not greater than this value
schema:
type: number
AmountWithoutVatCurrency:
name: amountWithoutVatCurrency
in: query
description: Filter invoices by amount without VAT currency
schema:
type: string
IssueDateFrom:
name: issueDateFrom
in: query
description: Select invoices with issue date not lesser than this date
schema:
type: string
format: date
example: '2021-01-15'
IssueDateTo:
name: issueDateTo
in: query
description: Select invoices with issue date not greater than this date
schema:
type: string
format: date
example: '2021-01-15'
UploadTimeFrom:
name: uploadTimeFrom
in: query
description: Select invoices with upload time not lesser than this time
schema:
type: string
format: date-time
example: '2021-01-02T15:04:05.999+00:00'
UploadTimeTo:
name: uploadTimeTo
in: query
description: Select invoices with upload date lesser than this time
schema:
type: string
format: date
example: '2021-01-02T15:04:05.999+00:00'
CustomerName:
name: customerName
in: query
description: Select invoices with customer name containing this value
schema:
type: string
example: 'Company 1'
SupplierName:
name: supplierName
in: query
description: Select invoices with supplier name containing this value
schema:
type: string
example: 'Company 1'
CustomerIco:
name: customerIco
in: query
description: Filter invoices by customer IČO
schema:
type: string
example: '11190993'
SupplierIco:
name: supplierIco
in: query
description: Filter invoices by supplier IČO
schema:
type: string
example: '11190993'
DraftId:
name: draftId
in: path
description: Draft ID
required: true
schema:
type: string
format: uuid
requestBodies:
PatchUser:
content:
application/json:
schema:
type: object
properties:
serviceAccountPublicKey:
type: string
responses:
Login:
description: User is sucessfully logged in.
content:
application/json:
schema:
allOf:
- $ref: '#/components/schemas/UserInfo'
- type: object
properties:
token:
type: string
format: uuid
Logout:
description: User is successfully logged out.
content:
application/json:
schema:
type: object
properties:
logout:
type: string
example: successful
Error:
description: There was an error
content:
application/json:
schema:
$ref: '#/components/schemas/Error'