-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-spec.yaml
More file actions
545 lines (520 loc) · 13.5 KB
/
api-spec.yaml
File metadata and controls
545 lines (520 loc) · 13.5 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
openapi: 3.0.3
info:
title: Ledgerline API
version: 1.0.0
description: >-
API for document ingestion, retrieval, and agentic querying in the Ledgerline
PageIndex pipeline.
servers:
- url: http://localhost:8083
description: Development (API Gateway)
- url: https://api.yourdomain.com
description: Production
tags:
- name: Health
- name: Documents
- name: Query
- name: CacheInternal
paths:
/health:
get:
tags: [Health]
summary: Service health check
operationId: getHealth
responses:
'200':
description: Service is healthy
content:
application/json:
schema:
type: object
properties:
status:
type: string
example: ok
service:
type: string
example: api-gateway
required: [status, service]
/documents/upload:
post:
tags: [Documents]
summary: Upload a PDF document
description: >-
This endpoint is served by the ingestion service during local development.
operationId: uploadDocument
servers:
- url: http://localhost:8080
description: Development (Ingestion Service)
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required: [file]
properties:
file:
type: string
format: binary
responses:
'200':
description: Document uploaded successfully
content:
application/json:
schema:
$ref: '#/components/schemas/UploadResponse'
'400':
$ref: '#/components/responses/BadRequest'
'413':
$ref: '#/components/responses/PayloadTooLarge'
'500':
$ref: '#/components/responses/InternalError'
/documents:
get:
tags: [Documents]
summary: List processed documents
operationId: listDocuments
parameters:
- $ref: '#/components/parameters/Limit'
- $ref: '#/components/parameters/Offset'
- $ref: '#/components/parameters/Sort'
responses:
'200':
description: Documents list
headers:
X-Total-Count:
schema:
type: integer
description: Total number of documents
X-Page-Count:
schema:
type: integer
description: Total pages for current pagination strategy
content:
application/json:
schema:
$ref: '#/components/schemas/DocumentsListResponse'
/documents/{doc_id}:
get:
tags: [Documents]
summary: Get document metadata
operationId: getDocumentById
parameters:
- $ref: '#/components/parameters/DocId'
responses:
'200':
description: Document metadata
content:
application/json:
schema:
$ref: '#/components/schemas/Document'
'404':
$ref: '#/components/responses/DocumentNotFound'
/documents/{doc_id}/tree:
get:
tags: [Documents]
summary: Get document tree structure
operationId: getDocumentTree
parameters:
- $ref: '#/components/parameters/DocId'
responses:
'200':
description: Tree retrieved
content:
application/json:
schema:
$ref: '#/components/schemas/DocumentTreeResponse'
'404':
$ref: '#/components/responses/DocumentNotFound'
/query:
post:
tags: [Query]
summary: Submit a query for processing
operationId: createQuery
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/QueryRequest'
responses:
'202':
description: Query accepted for processing
content:
application/json:
schema:
$ref: '#/components/schemas/QueryAcceptedResponse'
'400':
$ref: '#/components/responses/BadRequest'
'404':
$ref: '#/components/responses/DocumentNotFound'
'429':
$ref: '#/components/responses/RateLimitExceeded'
'500':
$ref: '#/components/responses/InternalError'
/query/{query_id}:
get:
tags: [Query]
summary: Get query status or completed result
operationId: getQueryById
parameters:
- $ref: '#/components/parameters/QueryId'
responses:
'200':
description: Query completed
content:
application/json:
schema:
$ref: '#/components/schemas/QueryCompletedResponse'
'202':
description: Query still processing
content:
application/json:
schema:
$ref: '#/components/schemas/QueryInProgressResponse'
'404':
$ref: '#/components/responses/QueryNotFound'
'500':
$ref: '#/components/responses/InternalError'
/ws:
get:
tags: [Query]
summary: WebSocket endpoint for streaming query responses
operationId: websocketQueryStream
description: >-
Upgrade this HTTP endpoint to WebSocket and exchange JSON messages for
acknowledgment, status updates, reasoning, answer, completion, and error
events.
responses:
'101':
description: Switching Protocols (WebSocket upgrade successful)
'400':
$ref: '#/components/responses/BadRequest'
/cache/tree/{doc_id}:
get:
tags: [CacheInternal]
summary: Get cached tree from cache service
operationId: getCachedTree
servers:
- url: http://localhost:8082
description: Development (Cache Service)
parameters:
- $ref: '#/components/parameters/DocId'
responses:
'200':
description: Cached tree found
content:
application/json:
schema:
type: object
properties:
tree:
$ref: '#/components/schemas/TreeNode'
required: [tree]
'404':
description: Not found
content:
application/json:
schema:
type: object
properties:
error:
type: string
example: Not found
required: [error]
/cache/stats:
get:
tags: [CacheInternal]
summary: Get cache statistics
operationId: getCacheStats
servers:
- url: http://localhost:8082
description: Development (Cache Service)
responses:
'200':
description: Cache statistics
content:
application/json:
schema:
$ref: '#/components/schemas/CacheStatsResponse'
components:
parameters:
DocId:
name: doc_id
in: path
required: true
schema:
type: string
format: uuid
description: Document UUID
QueryId:
name: query_id
in: path
required: true
schema:
type: string
format: uuid
description: Query UUID
Limit:
name: limit
in: query
required: false
schema:
type: integer
minimum: 1
maximum: 100
default: 10
Offset:
name: offset
in: query
required: false
schema:
type: integer
minimum: 0
default: 0
Sort:
name: sort
in: query
required: false
schema:
type: string
default: -created_at
schemas:
ErrorResponse:
type: object
properties:
error:
type: string
status:
type: string
example: error
code:
type: string
required: [error, status, code]
UploadResponse:
type: object
properties:
doc_id:
type: string
format: uuid
status:
type: string
example: uploaded
message:
type: string
example: Document uploaded successfully
required: [doc_id, status, message]
Document:
type: object
properties:
doc_id:
type: string
format: uuid
filename:
type: string
uploaded_at:
type: string
format: date-time
pages:
type: integer
minimum: 1
status:
type: string
example: completed
tree_generated_at:
type: string
format: date-time
required: [doc_id, filename, uploaded_at, pages, status]
DocumentsListResponse:
type: object
properties:
documents:
type: array
items:
$ref: '#/components/schemas/Document'
count:
type: integer
required: [documents, count]
TreeNode:
type: object
properties:
title:
type: string
node_id:
type: string
start_index:
type: integer
end_index:
type: integer
summary:
type: string
children:
type: array
items:
$ref: '#/components/schemas/TreeNode'
DocumentTreeResponse:
type: object
properties:
doc_id:
type: string
format: uuid
tree:
$ref: '#/components/schemas/TreeNode'
required: [doc_id, tree]
QueryRequest:
type: object
properties:
doc_id:
type: string
format: uuid
question:
type: string
include_sources:
type: boolean
default: true
required: [doc_id, question]
Source:
type: object
properties:
node_id:
type: string
title:
type: string
pages:
type: string
relevance_score:
type: number
format: float
required: [node_id, title, pages]
QueryAcceptedResponse:
type: object
properties:
query_id:
type: string
format: uuid
status:
type: string
example: processing
estimated_time_seconds:
type: integer
required: [query_id, status]
QueryInProgressResponse:
type: object
properties:
query_id:
type: string
format: uuid
status:
type: string
example: processing
progress:
type: string
estimated_time_remaining_seconds:
type: integer
required: [query_id, status]
QueryCompletedResponse:
type: object
properties:
query_id:
type: string
format: uuid
status:
type: string
example: completed
answer:
type: string
sources:
type: array
items:
$ref: '#/components/schemas/Source'
processing_time_ms:
type: integer
confidence:
type: number
format: float
required: [query_id, status, answer]
CacheStatsResponse:
type: object
properties:
hits:
type: integer
misses:
type: integer
cached_items:
type: integer
hit_rate:
type: number
format: float
required: [hits, misses, cached_items, hit_rate]
responses:
BadRequest:
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Missing required field
status: error
code: INVALID_REQUEST
PayloadTooLarge:
description: Uploaded file exceeds size limit
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Uploaded file exceeds size limit
status: error
code: FILE_TOO_LARGE
InternalError:
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Unexpected server error
status: error
code: INTERNAL_ERROR
DocumentNotFound:
description: Document not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Document not found
status: error
code: DOCUMENT_NOT_FOUND
QueryNotFound:
description: Query not found
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Query not found or expired
status: error
code: QUERY_NOT_FOUND
RateLimitExceeded:
description: Too many requests
headers:
X-RateLimit-Limit:
schema:
type: integer
X-RateLimit-Remaining:
schema:
type: integer
X-RateLimit-Reset:
schema:
type: integer
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
example:
error: Too many requests from this IP
status: error
code: RATE_LIMIT_EXCEEDED