forked from tleyden/open-ocr
-
Notifications
You must be signed in to change notification settings - Fork 2
/
OpenApi31.json
565 lines (565 loc) · 15.5 KB
/
OpenApi31.json
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
{
"openapi": "3.1.0",
"info": {
"title": "OpenOCR",
"description": "OpenOCR is a wrapper around Tesseract easily deployable as a service",
"contact": {
"name": "xf0e",
"email": "[email protected]"
},
"version": "1.8.1"
},
"jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
"servers": [
{
"url": "https://localhost:8080",
"variables": {}
},
{
"url": "http://localhost:8080",
"variables": {}
}
],
"paths": {
"/ocr": {
"post": {
"tags": [
"ocr"
],
"summary": "addOCR",
"description": "place ocr request",
"operationId": "addOCR",
"parameters": [],
"requestBody": {
"description": "Pass image url and other info to decode image to text via OCR",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DecodeOCR1"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"headers": {},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiResponse"
}
}
}
},
"400": {
"description": "Invalid input",
"headers": {},
"content": {
"text/plain": {
"schema": {
"pattern": "^[a-zA-Z0-9]{27}$",
"type": "string",
"description": "Unable to unmarshal json, malformed request. RequestID 26EaJxRYY2njljk9kLhTMSCGgeI",
"contentMediaType": "text/plain"
}
}
}
},
"503": {
"description": "Service Unavailable",
"headers": {},
"content": {
"text/plain": {
"schema": {
"pattern": "^[a-zA-Z0-9]{27}$",
"type": "string",
"description": "Unable to unmarshal json, malformed request. RequestID 26EaJxRYY2njljk9kLhTMSCGgeI",
"contentMediaType": "text/plain"
}
}
}
}
},
"deprecated": false
},
"parameters": []
},
"/ocr-status": {
"post": {
"tags": [
"ocr-status"
],
"summary": "ocr-status",
"description": "returns status of given request, submit id",
"operationId": "ocr-status",
"parameters": [],
"requestBody": {
"description": "Pass request id to get the status of that request",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/OCRStatus"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"headers": {},
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiResponse"
}
}
}
},
"400": {
"description": "client error",
"headers": {},
"content": {
"text/plain": {
"schema": {
"pattern": "^[a-zA-Z0-9]{27}$",
"type": "string",
"description": "Unable to unmarshal json, malformed request. RequestID 26EaJxRYY2njljk9kLhTMSCGgeI",
"contentMediaType": "text/plain"
}
}
}
},
"500": {
"description": "internal server error",
"headers": {},
"content": {
"text/plain": {
"schema": {
"pattern": "^[a-zA-Z0-9]{27}$",
"type": "string",
"description": "Unable to unmarshal json, malformed request. RequestID 26EaJxRYY2njljk9kLhTMSCGgeI",
"contentMediaType": "text/plain"
}
}
}
}
},
"deprecated": false
},
"parameters": []
}
},
"components": {
"schemas": {
"DecodeOCR": {
"title": "DecodeOCR",
"required": [
"engine"
],
"type": "object",
"properties": {
"deffered": {
"type": "boolean",
"description": "if set (default is false) the connection will be reset after request is placed. The client have to either set reply_to or poll to on /orc-status get the request.",
"default": false
},
"reply_to": {
"maxLength": 200,
"minLength": 5,
"type": "string",
"description": "if set the Server will deliver the result to the given adress",
"examples": [
"http://localhost:8888/postback-ocr"
]
},
"engine": {
"type": "string"
},
"preprocessors": {
"type": "array",
"items": {
"maxLength": 20,
"minLength": 3,
"type": "string"
},
"description": "can have one ore more values. all preprocessors will run in a chain before ocr is performed. Currenly only convert-pdf can be used if engine is tesseract."
}
},
"discriminator": {
"propertyName": "engine"
}
},
"sandwichengine": {
"title": "sandwichengine",
"allOf": [
{
"$ref": "#/components/schemas/DecodeOCR2"
},
{
"type": "object",
"properties": {
"doc_type": {
"maxLength": 30,
"minLength": 5,
"type": "string",
"description": "the service can prioritise some document types if the admin has configured document types priorities."
},
"page_number": {
"minimum": 1.0,
"type": "integer",
"description": "only used for logging now",
"contentEncoding": "int32"
},
"time_out": {
"minimum": 10.0,
"type": "integer",
"description": "You can set the maximum processing time for a particular request. If timeout has been reached prior finisching request the service will stop processing",
"contentEncoding": "int32"
},
"user_agent": {
"maxLength": 100,
"minLength": 3,
"type": "string",
"description": "please always set the user-agent for loggin purposes"
},
"reference_id": {
"maxLength": 100,
"minLength": 3,
"type": "string",
"description": "please always set the reference ID (e.g. Internal job ID)"
},
"engine_args": {
"$ref": "#/components/schemas/EngineArgs"
}
}
}
]
},
"tesseractengine": {
"title": "tesseractengine",
"allOf": [
{
"$ref": "#/components/schemas/DecodeOCR2"
},
{
"type": "object",
"properties": {
"inplace_decode": {
"type": "boolean",
"description": "If true, will attempt to do ocr decode in-place rather than queuing a message on RabbitMQ for worker processing. Useful for local testing, not recommended for production.",
"default": false
},
"engine_args": {
"$ref": "#/components/schemas/EngineArgs1"
}
}
}
]
},
"imageBase64": {
"title": "imageBase64",
"required": [
"img_base64"
],
"type": "object",
"properties": {
"img_base64": {
"minLength": 5,
"type": "string",
"description": "Base64 encoded document to process"
}
}
},
"imageURL": {
"title": "imageURL",
"required": [
"img_url"
],
"type": "object",
"properties": {
"img_url": {
"maxLength": 200,
"minLength": 5,
"type": "string",
"description": "The URL of the image or the pdf to process. If set, ocr server will try to download the image"
}
}
},
"ApiResponse": {
"title": "ApiResponse",
"required": [
"text",
"id",
"status"
],
"type": "object",
"properties": {
"text": {
"type": "string",
"description": "Contains either the OCR-Result of the error message if field status is set to error. Text can contain a plain text or a base64 encoded file. It depends on the parameter ocr_type at placing request"
},
"id": {
"maxLength": 27,
"minLength": 27,
"pattern": "^[a-zA-Z0-9]{27}$",
"type": "string",
"description": "K-Sortable Unique IDentifier",
"examples": [
"1sDRnIKpJSijZaMXmXoCqQVc32N"
]
},
"status": {
"$ref": "#/components/schemas/Status"
}
}
},
"OCRStatus": {
"title": "OCRStatus",
"required": [
"img_url"
],
"type": "object",
"properties": {
"img_url": {
"maxLength": 27,
"minLength": 27,
"pattern": "^[a-zA-Z0-9]{27}$",
"type": "string",
"description": "The ID of the Request, ID is K-Sortable Unique IDentifier",
"examples": [
"26EaJxRYY2njljk9kLhTMSCGgeI"
]
}
},
"description": "status of request to given ID"
},
"DecodeOCR2": {
"title": "DecodeOCR2",
"required": [
"engine"
],
"type": "object",
"properties": {
"engine": {
"type": "string"
}
},
"discriminator": {
"propertyName": "engine",
"mapping": {
"sandwich": "sandwichengine",
"tesseract": "tesseractengine"
}
}
},
"EngineArgs": {
"title": "EngineArgs",
"type": "object",
"properties": {
"ocr_type": {
"$ref": "#/components/schemas/OcrType"
},
"result_optimize": {
"type": "boolean",
"description": "If set the resulting pdf will be delivered with pdf 1.7 specification and the resolution at 300 x 300 (prepress settings of gs)",
"default": false
},
"config_vars": {
"maxLength": 100,
"minLength": 3,
"type": "string",
"description": "Config vars - equivalent of -c args to tesseract"
},
"psm": {
"$ref": "#/components/schemas/Psm"
},
"lang": {
"$ref": "#/components/schemas/Lang"
}
},
"description": "The OCR engine arguments to pass (engine-specific)"
},
"EngineArgs1": {
"title": "EngineArgs1",
"type": "object",
"properties": {
"config_vars": {
"maxLength": 100,
"minLength": 3,
"type": "string",
"description": "Config vars - equivalent of -c args to tesseract"
},
"psm": {
"$ref": "#/components/schemas/Psm"
},
"lang": {
"$ref": "#/components/schemas/Lang"
}
},
"description": "The OCR engine arguments to pass (engine-specific)"
},
"Lang": {
"title": "Lang",
"enum": [
"eng",
"ara",
"bel",
"ben",
"bul",
"ces",
"dan",
"deu",
"ell",
"fin",
"fra",
"heb",
"hin",
"ind",
"isl",
"ita",
"jpn",
"kor",
"nld",
"nor",
"pol",
"por",
"ron",
"rus",
"spa",
"swe",
"tha",
"tur",
"ukr",
"vie",
"chi-sim",
"chi-tra"
],
"type": "string",
"description": "The language to use. If omitted, will use English",
"examples": [
"eng"
]
},
"OcrType": {
"title": "OcrType",
"enum": [
"txt",
"combinedpdf",
"ocrlayeronly"
],
"type": "string",
"description": "txt will return text, combinedpdf will return original pdf with ocr layer, if ocrlayeronly is set the service will return a pdf with orc layer (in pdf viewer the text is invisible, but searchable). All values will return base64 encoded value except for an erroneuous request. In this case the service will terurn the same object but the key text will contain human error",
"examples": [
"txt"
]
},
"Psm": {
"title": "Psm",
"enum": [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
],
"type": "integer",
"description": "Page Segment Mode, equivalent of -psm arg to tesseract. To use default, omit this field from the JSON.",
"examples": [
0
]
},
"Status": {
"title": "Status",
"enum": [
"done",
"error",
"not found",
"processing"
],
"type": "string",
"description": "can be error, not found, processing or done",
"examples": [
"done"
]
},
"DecodeOCR1": {
"oneOf": [
{
"oneOf": [
{
"$ref": "#/components/schemas/imageBase64"
},
{
"$ref": "#/components/schemas/imageURL"
}
]
},
{
"oneOf": [
{
"$ref": "#/components/schemas/imageBase64"
},
{
"$ref": "#/components/schemas/imageURL"
}
]
}
],
"discriminator": {
"propertyName": "engine",
"mapping": {
"sandwich": "sandwichengine",
"tesseract": "tesseractengine"
}
}
},
"sandwich engine1": {
"oneOf": [
{
"$ref": "#/components/schemas/imageBase64"
},
{
"$ref": "#/components/schemas/imageURL"
}
]
},
"tesseract engine1": {
"oneOf": [
{
"$ref": "#/components/schemas/imageBase64"
},
{
"$ref": "#/components/schemas/imageURL"
}
]
}
}
},
"tags": [
{
"name": "OpenOCR",
"description": "Service wrapper around Tesseract",
"externalDocs": {
"description": "Find out more",
"url": "https://github.com/xf0e/open-ocr"
}
},
{
"name": "ocr",
"description": ""
},
{
"name": "ocr-status",
"description": ""
}
]
}