forked from tleyden/open-ocr
-
Notifications
You must be signed in to change notification settings - Fork 2
/
openapi3.0.yml
381 lines (381 loc) · 11.7 KB
/
openapi3.0.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
openapi: 3.0.1
info:
version: 1.8.1
title: OpenOCR
description: OpenOCR is a wrapper around Tesseract easily deployable as a service
contact:
name: xf0e
email: [email protected]
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
tags:
- name: OpenOCR
description: Service wrapper around Tesseract
externalDocs:
description: Find out more
url: 'https://github.com/xf0e/open-ocr'
paths:
/ocr:
post:
tags:
- ocr
summary: Place a new OCR request
description: 'place ocr request'
operationId: addOCR
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/DecodeOCR'
description: Pass image url and other info to decode image to text via OCR
required: true
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'400':
description: Invalid input
content:
text/plain:
schema:
$ref: '#/components/schemas/ApiResponseNOK'
'503':
description: Service Unavailable
content:
text/plain:
schema:
$ref: '#/components/schemas/ApiResponseNOK'
/ocr-status:
post:
tags:
- ocr-status
summary: returns status of given request
description: 'returns status of given request, submit id'
operationId: ocr-status
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/OCRStatus'
description: Pass request id to get the status of that request
required: true
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/ApiResponse'
'400':
description: client error
content:
text/plain:
schema:
$ref: '#/components/schemas/ApiResponseNOK'
'500':
description: internal server error
content:
text/plain:
schema:
$ref: '#/components/schemas/ApiResponseNOK'
servers:
- url: 'https://localhost:8080'
- url: 'http://localhost:8080'
components:
schemas:
DecodeOCR:
properties:
deffered:
type: boolean
default: false
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.
reply_to:
type: string
format: uri
nullable: false
minLength: 5
maxLength: 200
example: 'http://localhost:8888/postback-ocr'
description: if set the Server will deliver the result to the given adress
engine:
type: string
nullable: false
description: only use sandwich or tesseract in production.
default: sandwich
enum:
- sandwich
- tesseract
preprocessors:
type: array
nullable: false
items:
type: string
minItems: 1
maxLength: 20
minLength: 3
example: convert-pdf
nullable: false
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.
oneOf:
- $ref: '#/components/schemas/DecodeORCSandwich'
- $ref: '#/components/schemas/DecodeORCTesseract'
discriminator:
propertyName: engine
mapping:
sandwich: '#/components/schemas/DecodeORCSandwich'
tesseract: '#/components/schemas/DecodeORCTesseract'
DecodeORCSandwich:
title: sandwich engine
type: object
properties:
doc_type:
type: string
nullable: false
minLength: 5
maxLength: 30
description: the service can prioritise some document types if the admin has configured document types priorities.
page_number:
type: integer
format: int32
minimum: 1
description: only used for logging now
time_out:
type: integer
format: int32
minimum: 10
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
user_agent:
type: string
minLength: 3
maxLength: 100
nullable: false
description: please always set the user-agent for loggin purposes
reference_id:
type: string
minLength: 3
maxLength: 100
nullable: false
description: please always set the reference ID (e.g. Internal job ID)
engine_args:
type: object
description: The OCR engine arguments to pass (engine-specific)
properties:
ocr_type:
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'
enum:
- txt
- combinedpdf
- ocrlayeronly
result_optimize:
type: boolean
default: false
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)
config_vars:
type: string
minLength: 3
maxLength: 100
nullable: false
description: Config vars - equivalent of -c args to tesseract
psm:
type: string
nullable: false
description: 'Page Segment Mode, equivalent of -psm arg to tesseract. To use default, omit this field from the JSON.'
enum:
- '0'
- '1'
- '2'
- '3'
- '4'
- '5'
- '6'
- '7'
- '8'
- '9'
- '10'
lang:
type: string
nullable: false
description: 'The language to use. If omitted, will use English'
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
oneOf:
- $ref: '#/components/schemas/imageBase64'
- $ref: '#/components/schemas/imageURL'
DecodeORCTesseract:
title: tesseract engine
type: object
properties:
inplace_decode:
type: boolean
default: false
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.'
engine_args:
type: object
description: The OCR engine arguments to pass (engine-specific)
properties:
config_vars:
type: string
minLength: 3
maxLength: 100
nullable: false
description: Config vars - equivalent of -c args to tesseract
psm:
type: string
nullable: false
description: 'Page Segment Mode, equivalent of -psm arg to tesseract. To use default, omit this field from the JSON.'
enum:
- '0'
- '1'
- '2'
- '3'
- '4'
- '5'
- '6'
- '7'
- '8'
- '9'
- '10'
lang:
type: string
nullable: false
description: 'The language to use. If omitted, will use English'
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
oneOf:
- $ref: '#/components/schemas/imageBase64'
- $ref: '#/components/schemas/imageURL'
imageBase64:
type: object
properties:
img_base64:
type: string
format: byte
nullable: false
minLength: 5
description: Base64 encoded document to process
required:
- img_base64
imageURL:
type: object
properties:
img_url:
type: string
format: uri
minLength: 5
maxLength: 200
nullable: false
description: 'The URL of the image or the pdf to process. If set, ocr server will try to download the image'
required:
- img_url
ApiResponse:
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:
type: string
example: 1sDRnIKpJSijZaMXmXoCqQVc32N
description: K-Sortable Unique IDentifier
nullable: false
pattern: '^[a-zA-Z0-9]{27}$'
maxLength: 27
minLength: 27
status:
type: string
nullable: false
description: 'can be error, not found, processing or done'
enum:
- done
- error
- not found
- processing
required:
- text
- status
- id
ApiResponseNOK:
type: string
pattern: '^[a-zA-Z0-9]{27}$'
example: '26EaJxRYY2njljk9kLhTMSCGgeI'
description: 'Unable to unmarshal json, malformed request. RequestID 26EaJxRYY2njljk9kLhTMSCGgeI'
OCRStatus:
type: object
description: status of request to given ID
properties:
img_url:
type: string
description: 'The ID of the Request, ID is K-Sortable Unique IDentifier'
example: 26EaJxRYY2njljk9kLhTMSCGgeI
pattern: '^[a-zA-Z0-9]{27}$'
maxLength: 27
minLength: 27
required:
- img_url