@polygonlabs/example-schemas 0.0.0 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/openapi.json ADDED
@@ -0,0 +1,807 @@
1
+ {
2
+ "openapi": "3.0.0",
3
+ "info": {
4
+ "title": "Example REST API",
5
+ "version": "0.1.0",
6
+ "description": "Stubbed REST API demonstrating the schemas/service/client monorepo pattern."
7
+ },
8
+ "servers": [
9
+ {
10
+ "url": "/"
11
+ }
12
+ ],
13
+ "components": {
14
+ "securitySchemes": {
15
+ "ApiKeyAuth": {
16
+ "type": "apiKey",
17
+ "in": "header",
18
+ "name": "x-api-key",
19
+ "description": "Shared secret. Required on operations declaring ApiKeyAuth."
20
+ }
21
+ },
22
+ "schemas": {
23
+ "HealthCheckResponse": {
24
+ "type": "object",
25
+ "properties": {
26
+ "success": {
27
+ "type": "boolean"
28
+ }
29
+ },
30
+ "required": [
31
+ "success"
32
+ ]
33
+ },
34
+ "ErrorResponse": {
35
+ "type": "object",
36
+ "properties": {
37
+ "error": {
38
+ "type": "boolean",
39
+ "enum": [
40
+ true
41
+ ]
42
+ },
43
+ "message": {
44
+ "type": "string"
45
+ },
46
+ "info": {
47
+ "type": "object",
48
+ "additionalProperties": {
49
+ "nullable": true
50
+ }
51
+ }
52
+ },
53
+ "required": [
54
+ "error",
55
+ "message"
56
+ ],
57
+ "description": "Standard error response shape from `@polygonlabs/express`'s `createErrorHandler`. `info` is present when the underlying `HTTPError` carries structured info (e.g. validation failures, domain-specific context); absent for plain errors and most non-validation HTTPErrors."
58
+ },
59
+ "HelloResponse": {
60
+ "type": "object",
61
+ "properties": {
62
+ "message": {
63
+ "type": "string"
64
+ }
65
+ },
66
+ "required": [
67
+ "message"
68
+ ]
69
+ },
70
+ "BlockNumberResponse": {
71
+ "type": "object",
72
+ "properties": {
73
+ "blockNumber": {
74
+ "type": "string",
75
+ "pattern": "^-?\\d+$",
76
+ "description": "Block height — fits in int64."
77
+ }
78
+ },
79
+ "required": [
80
+ "blockNumber"
81
+ ],
82
+ "description": "Latest block number from the configured RPC endpoint"
83
+ },
84
+ "BlockMetadata": {
85
+ "type": "object",
86
+ "properties": {
87
+ "number": {
88
+ "type": "string",
89
+ "pattern": "^-?\\d+$"
90
+ },
91
+ "hash": {
92
+ "type": "string"
93
+ },
94
+ "parentHash": {
95
+ "type": "string"
96
+ },
97
+ "timestamp": {
98
+ "type": "string",
99
+ "pattern": "^-?\\d+$"
100
+ }
101
+ },
102
+ "required": [
103
+ "number",
104
+ "hash",
105
+ "parentHash",
106
+ "timestamp"
107
+ ],
108
+ "description": "Block header metadata for a specific height"
109
+ },
110
+ "ValidationErrorResponse": {
111
+ "type": "object",
112
+ "properties": {
113
+ "error": {
114
+ "type": "boolean",
115
+ "enum": [
116
+ true
117
+ ]
118
+ },
119
+ "message": {
120
+ "type": "string"
121
+ },
122
+ "info": {
123
+ "$ref": "#/components/schemas/ValidationErrorInfo"
124
+ }
125
+ },
126
+ "required": [
127
+ "error",
128
+ "message",
129
+ "info"
130
+ ],
131
+ "description": "Narrowed `ErrorResponse` for 400s emitted by the registry-driven router when request validation fails. `info` is non-optional and carries the section-keyed `ValidationErrorInfo` shape."
132
+ },
133
+ "ValidationErrorInfo": {
134
+ "type": "object",
135
+ "properties": {
136
+ "params": {
137
+ "$ref": "#/components/schemas/ZodErrorTree"
138
+ },
139
+ "query": {
140
+ "$ref": "#/components/schemas/ZodErrorTree"
141
+ },
142
+ "body": {
143
+ "$ref": "#/components/schemas/ZodErrorTree"
144
+ },
145
+ "headers": {
146
+ "$ref": "#/components/schemas/ZodErrorTree"
147
+ }
148
+ },
149
+ "description": "Section-keyed map of request validation failures. Only sections that failed appear; each value is the `z.treeifyError` tree for that section. Clients can wire e.g. `info.body.properties.label.errors[0]` directly into field-level UI feedback rather than walking a flat issue list."
150
+ },
151
+ "ZodErrorTree": {
152
+ "type": "object",
153
+ "properties": {
154
+ "errors": {
155
+ "type": "array",
156
+ "items": {
157
+ "type": "string"
158
+ }
159
+ },
160
+ "properties": {
161
+ "type": "object",
162
+ "additionalProperties": {
163
+ "$ref": "#/components/schemas/ZodErrorTree"
164
+ }
165
+ },
166
+ "items": {
167
+ "type": "array",
168
+ "items": {
169
+ "$ref": "#/components/schemas/ZodErrorTree"
170
+ }
171
+ }
172
+ },
173
+ "required": [
174
+ "errors"
175
+ ],
176
+ "description": "Recursive Zod validation error tree (the output of `z.treeifyError`). `errors` carries the messages at this node; `properties` keys nested object errors by field name; `items` indexes nested array errors."
177
+ },
178
+ "Message": {
179
+ "type": "object",
180
+ "properties": {
181
+ "id": {
182
+ "type": "string",
183
+ "format": "uuid"
184
+ },
185
+ "text": {
186
+ "type": "string",
187
+ "minLength": 1
188
+ },
189
+ "createdAt": {
190
+ "type": "string",
191
+ "format": "date-time"
192
+ }
193
+ },
194
+ "required": [
195
+ "id",
196
+ "text",
197
+ "createdAt"
198
+ ]
199
+ },
200
+ "CreateMessageRequest": {
201
+ "type": "object",
202
+ "properties": {
203
+ "text": {
204
+ "type": "string",
205
+ "minLength": 1,
206
+ "maxLength": 280
207
+ }
208
+ },
209
+ "required": [
210
+ "text"
211
+ ]
212
+ },
213
+ "MessageList": {
214
+ "type": "object",
215
+ "properties": {
216
+ "items": {
217
+ "type": "array",
218
+ "items": {
219
+ "$ref": "#/components/schemas/Message"
220
+ }
221
+ },
222
+ "nextCursor": {
223
+ "type": "string",
224
+ "nullable": true
225
+ }
226
+ },
227
+ "required": [
228
+ "items",
229
+ "nextCursor"
230
+ ]
231
+ },
232
+ "Widget": {
233
+ "type": "object",
234
+ "properties": {
235
+ "id": {
236
+ "type": "string",
237
+ "format": "uuid"
238
+ },
239
+ "name": {
240
+ "type": "string",
241
+ "minLength": 1,
242
+ "maxLength": 120
243
+ }
244
+ },
245
+ "required": [
246
+ "id",
247
+ "name"
248
+ ]
249
+ },
250
+ "EventList": {
251
+ "type": "object",
252
+ "properties": {
253
+ "items": {
254
+ "type": "array",
255
+ "items": {
256
+ "$ref": "#/components/schemas/IndexedEvent"
257
+ }
258
+ },
259
+ "nextCursor": {
260
+ "type": "string",
261
+ "nullable": true
262
+ }
263
+ },
264
+ "required": [
265
+ "items",
266
+ "nextCursor"
267
+ ]
268
+ },
269
+ "IndexedEvent": {
270
+ "type": "object",
271
+ "properties": {
272
+ "id": {
273
+ "type": "string"
274
+ },
275
+ "chain": {
276
+ "type": "integer"
277
+ },
278
+ "contractAddress": {
279
+ "type": "string"
280
+ },
281
+ "eventName": {
282
+ "type": "string"
283
+ },
284
+ "blockNumber": {
285
+ "type": "integer"
286
+ },
287
+ "transactionIndex": {
288
+ "type": "integer"
289
+ },
290
+ "txHash": {
291
+ "type": "string"
292
+ },
293
+ "logIndex": {
294
+ "type": "integer"
295
+ },
296
+ "args": {
297
+ "type": "object",
298
+ "additionalProperties": {
299
+ "anyOf": [
300
+ {
301
+ "type": "string"
302
+ },
303
+ {
304
+ "type": "number"
305
+ },
306
+ {
307
+ "type": "boolean"
308
+ }
309
+ ]
310
+ }
311
+ },
312
+ "indexedAt": {
313
+ "type": "integer"
314
+ }
315
+ },
316
+ "required": [
317
+ "id",
318
+ "chain",
319
+ "contractAddress",
320
+ "eventName",
321
+ "blockNumber",
322
+ "txHash",
323
+ "logIndex",
324
+ "args",
325
+ "indexedAt"
326
+ ]
327
+ }
328
+ },
329
+ "parameters": {}
330
+ },
331
+ "paths": {
332
+ "/health-check": {
333
+ "get": {
334
+ "operationId": "getHealthCheck",
335
+ "summary": "Liveness check",
336
+ "responses": {
337
+ "200": {
338
+ "description": "Service is alive",
339
+ "content": {
340
+ "application/json": {
341
+ "schema": {
342
+ "$ref": "#/components/schemas/HealthCheckResponse"
343
+ }
344
+ }
345
+ }
346
+ },
347
+ "500": {
348
+ "description": "Internal server error.",
349
+ "content": {
350
+ "application/json": {
351
+ "schema": {
352
+ "$ref": "#/components/schemas/ErrorResponse"
353
+ }
354
+ }
355
+ }
356
+ }
357
+ }
358
+ }
359
+ },
360
+ "/api/hello": {
361
+ "get": {
362
+ "operationId": "getHello",
363
+ "summary": "Hello world",
364
+ "responses": {
365
+ "200": {
366
+ "description": "Greeting response",
367
+ "content": {
368
+ "application/json": {
369
+ "schema": {
370
+ "$ref": "#/components/schemas/HelloResponse"
371
+ }
372
+ }
373
+ }
374
+ },
375
+ "500": {
376
+ "description": "Internal server error.",
377
+ "content": {
378
+ "application/json": {
379
+ "schema": {
380
+ "$ref": "#/components/schemas/ErrorResponse"
381
+ }
382
+ }
383
+ }
384
+ }
385
+ }
386
+ }
387
+ },
388
+ "/api/block-number": {
389
+ "get": {
390
+ "operationId": "getBlockNumber",
391
+ "summary": "Current block number",
392
+ "description": "Returns the latest block number from the configured RPC endpoint.",
393
+ "responses": {
394
+ "200": {
395
+ "description": "Latest block number",
396
+ "content": {
397
+ "application/json": {
398
+ "schema": {
399
+ "$ref": "#/components/schemas/BlockNumberResponse"
400
+ }
401
+ }
402
+ }
403
+ },
404
+ "500": {
405
+ "description": "Internal server error.",
406
+ "content": {
407
+ "application/json": {
408
+ "schema": {
409
+ "$ref": "#/components/schemas/ErrorResponse"
410
+ }
411
+ }
412
+ }
413
+ }
414
+ }
415
+ }
416
+ },
417
+ "/api/blocks/{blockNumber}": {
418
+ "get": {
419
+ "operationId": "getBlockMetadata",
420
+ "summary": "Block metadata by height",
421
+ "description": "Looks up a block by its height via RPC and returns header metadata.",
422
+ "security": [
423
+ {
424
+ "ApiKeyAuth": []
425
+ }
426
+ ],
427
+ "parameters": [
428
+ {
429
+ "schema": {
430
+ "type": "string",
431
+ "pattern": "^-?\\d+$"
432
+ },
433
+ "required": true,
434
+ "name": "blockNumber",
435
+ "in": "path"
436
+ }
437
+ ],
438
+ "responses": {
439
+ "200": {
440
+ "description": "Block metadata",
441
+ "content": {
442
+ "application/json": {
443
+ "schema": {
444
+ "$ref": "#/components/schemas/BlockMetadata"
445
+ }
446
+ }
447
+ }
448
+ },
449
+ "400": {
450
+ "description": "Request failed schema validation.",
451
+ "content": {
452
+ "application/json": {
453
+ "schema": {
454
+ "$ref": "#/components/schemas/ValidationErrorResponse"
455
+ }
456
+ }
457
+ }
458
+ },
459
+ "401": {
460
+ "description": "Missing or invalid credentials.",
461
+ "content": {
462
+ "application/json": {
463
+ "schema": {
464
+ "$ref": "#/components/schemas/ErrorResponse"
465
+ }
466
+ }
467
+ }
468
+ },
469
+ "404": {
470
+ "description": "Block not found",
471
+ "content": {
472
+ "application/json": {
473
+ "schema": {
474
+ "$ref": "#/components/schemas/ErrorResponse"
475
+ }
476
+ }
477
+ }
478
+ },
479
+ "500": {
480
+ "description": "Internal server error.",
481
+ "content": {
482
+ "application/json": {
483
+ "schema": {
484
+ "$ref": "#/components/schemas/ErrorResponse"
485
+ }
486
+ }
487
+ }
488
+ }
489
+ }
490
+ }
491
+ },
492
+ "/api/messages": {
493
+ "post": {
494
+ "operationId": "createMessage",
495
+ "summary": "Create a message",
496
+ "requestBody": {
497
+ "content": {
498
+ "application/json": {
499
+ "schema": {
500
+ "$ref": "#/components/schemas/CreateMessageRequest"
501
+ }
502
+ }
503
+ }
504
+ },
505
+ "responses": {
506
+ "200": {
507
+ "description": "Message created",
508
+ "content": {
509
+ "application/json": {
510
+ "schema": {
511
+ "$ref": "#/components/schemas/Message"
512
+ }
513
+ }
514
+ }
515
+ },
516
+ "400": {
517
+ "description": "Request failed schema validation.",
518
+ "content": {
519
+ "application/json": {
520
+ "schema": {
521
+ "$ref": "#/components/schemas/ValidationErrorResponse"
522
+ }
523
+ }
524
+ }
525
+ },
526
+ "500": {
527
+ "description": "Internal server error.",
528
+ "content": {
529
+ "application/json": {
530
+ "schema": {
531
+ "$ref": "#/components/schemas/ErrorResponse"
532
+ }
533
+ }
534
+ }
535
+ }
536
+ }
537
+ },
538
+ "get": {
539
+ "operationId": "listMessages",
540
+ "summary": "List messages",
541
+ "parameters": [
542
+ {
543
+ "schema": {
544
+ "type": "string"
545
+ },
546
+ "required": false,
547
+ "name": "cursor",
548
+ "in": "query"
549
+ },
550
+ {
551
+ "schema": {
552
+ "type": "string",
553
+ "format": "date-time"
554
+ },
555
+ "required": false,
556
+ "name": "since",
557
+ "in": "query"
558
+ }
559
+ ],
560
+ "responses": {
561
+ "200": {
562
+ "description": "Page of messages",
563
+ "content": {
564
+ "application/json": {
565
+ "schema": {
566
+ "$ref": "#/components/schemas/MessageList"
567
+ }
568
+ }
569
+ }
570
+ },
571
+ "400": {
572
+ "description": "Request failed schema validation.",
573
+ "content": {
574
+ "application/json": {
575
+ "schema": {
576
+ "$ref": "#/components/schemas/ValidationErrorResponse"
577
+ }
578
+ }
579
+ }
580
+ },
581
+ "500": {
582
+ "description": "Internal server error.",
583
+ "content": {
584
+ "application/json": {
585
+ "schema": {
586
+ "$ref": "#/components/schemas/ErrorResponse"
587
+ }
588
+ }
589
+ }
590
+ }
591
+ }
592
+ }
593
+ },
594
+ "/api/messages/{id}": {
595
+ "get": {
596
+ "operationId": "getMessage",
597
+ "summary": "Get a message by id",
598
+ "parameters": [
599
+ {
600
+ "schema": {
601
+ "type": "string",
602
+ "format": "uuid"
603
+ },
604
+ "required": true,
605
+ "name": "id",
606
+ "in": "path"
607
+ }
608
+ ],
609
+ "responses": {
610
+ "200": {
611
+ "description": "Message",
612
+ "content": {
613
+ "application/json": {
614
+ "schema": {
615
+ "$ref": "#/components/schemas/Message"
616
+ }
617
+ }
618
+ }
619
+ },
620
+ "400": {
621
+ "description": "Request failed schema validation.",
622
+ "content": {
623
+ "application/json": {
624
+ "schema": {
625
+ "$ref": "#/components/schemas/ValidationErrorResponse"
626
+ }
627
+ }
628
+ }
629
+ },
630
+ "404": {
631
+ "description": "Not found",
632
+ "content": {
633
+ "application/json": {
634
+ "schema": {
635
+ "$ref": "#/components/schemas/ErrorResponse"
636
+ }
637
+ }
638
+ }
639
+ },
640
+ "500": {
641
+ "description": "Internal server error.",
642
+ "content": {
643
+ "application/json": {
644
+ "schema": {
645
+ "$ref": "#/components/schemas/ErrorResponse"
646
+ }
647
+ }
648
+ }
649
+ }
650
+ }
651
+ }
652
+ },
653
+ "/api/widgets/{id}": {
654
+ "get": {
655
+ "operationId": "getWidget",
656
+ "summary": "Get a widget by id",
657
+ "description": "Reads a widget from Firestore through a Redis cache (cache-aside). First read populates the cache; subsequent reads are served from it.",
658
+ "parameters": [
659
+ {
660
+ "schema": {
661
+ "type": "string",
662
+ "format": "uuid"
663
+ },
664
+ "required": true,
665
+ "name": "id",
666
+ "in": "path"
667
+ }
668
+ ],
669
+ "responses": {
670
+ "200": {
671
+ "description": "Widget",
672
+ "content": {
673
+ "application/json": {
674
+ "schema": {
675
+ "$ref": "#/components/schemas/Widget"
676
+ }
677
+ }
678
+ }
679
+ },
680
+ "400": {
681
+ "description": "Request failed schema validation.",
682
+ "content": {
683
+ "application/json": {
684
+ "schema": {
685
+ "$ref": "#/components/schemas/ValidationErrorResponse"
686
+ }
687
+ }
688
+ }
689
+ },
690
+ "404": {
691
+ "description": "Not found",
692
+ "content": {
693
+ "application/json": {
694
+ "schema": {
695
+ "$ref": "#/components/schemas/ErrorResponse"
696
+ }
697
+ }
698
+ }
699
+ },
700
+ "500": {
701
+ "description": "Internal server error.",
702
+ "content": {
703
+ "application/json": {
704
+ "schema": {
705
+ "$ref": "#/components/schemas/ErrorResponse"
706
+ }
707
+ }
708
+ }
709
+ }
710
+ }
711
+ }
712
+ },
713
+ "/events": {
714
+ "get": {
715
+ "operationId": "listEvents",
716
+ "summary": "List indexed on-chain events",
717
+ "description": "Returns decoded events indexed by example-indexer, newest-first, with optional chain / contractAddress / eventName filters and opaque-cursor pagination.",
718
+ "parameters": [
719
+ {
720
+ "schema": {
721
+ "type": "string",
722
+ "pattern": "^-?\\d+$"
723
+ },
724
+ "required": false,
725
+ "name": "chain",
726
+ "in": "query"
727
+ },
728
+ {
729
+ "schema": {
730
+ "type": "string"
731
+ },
732
+ "required": false,
733
+ "name": "contractAddress",
734
+ "in": "query"
735
+ },
736
+ {
737
+ "schema": {
738
+ "type": "string"
739
+ },
740
+ "required": false,
741
+ "name": "eventName",
742
+ "in": "query"
743
+ },
744
+ {
745
+ "schema": {
746
+ "type": "string"
747
+ },
748
+ "required": false,
749
+ "name": "cursor",
750
+ "in": "query"
751
+ },
752
+ {
753
+ "schema": {
754
+ "type": "string",
755
+ "pattern": "^\\d+$"
756
+ },
757
+ "required": false,
758
+ "name": "limit",
759
+ "in": "query"
760
+ }
761
+ ],
762
+ "responses": {
763
+ "200": {
764
+ "description": "Page of indexed events",
765
+ "content": {
766
+ "application/json": {
767
+ "schema": {
768
+ "$ref": "#/components/schemas/EventList"
769
+ }
770
+ }
771
+ }
772
+ },
773
+ "400": {
774
+ "description": "Request failed schema validation.",
775
+ "content": {
776
+ "application/json": {
777
+ "schema": {
778
+ "$ref": "#/components/schemas/ValidationErrorResponse"
779
+ }
780
+ }
781
+ }
782
+ },
783
+ "422": {
784
+ "description": "Malformed pagination cursor",
785
+ "content": {
786
+ "application/json": {
787
+ "schema": {
788
+ "$ref": "#/components/schemas/ErrorResponse"
789
+ }
790
+ }
791
+ }
792
+ },
793
+ "500": {
794
+ "description": "Internal server error.",
795
+ "content": {
796
+ "application/json": {
797
+ "schema": {
798
+ "$ref": "#/components/schemas/ErrorResponse"
799
+ }
800
+ }
801
+ }
802
+ }
803
+ }
804
+ }
805
+ }
806
+ }
807
+ }