Skip to content

Commit b4c404a

Browse files
author
regula-bot
committed
Merge remote-tracking branch 'origin/stable'
2 parents 0c0e66f + 728ac84 commit b4c404a

File tree

304 files changed

+24537
-37598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

304 files changed

+24537
-37598
lines changed

.github/workflows/pypi-publish.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/run-smoke-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Set up Python
1616
uses: actions/setup-python@v2
1717
with:
18-
python-version: 3.8
18+
python-version: 3.9
1919
- name: Install pipenv
2020
run: |
2121
python -m pip install --upgrade pip
@@ -27,4 +27,3 @@ jobs:
2727
working-directory: example
2828
env:
2929
API_BASE_PATH: "https://nightly-api.regulaforensics.com"
30-
TEST_LICENSE: ${{secrets.TEST_LICENSE}}

.openapi-generator-ignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ README.md
1111
.gitignore
1212
setup.py
1313
regula/documentreader/webclient/__init__.py
14+
pyproject.toml
15+
.github/workflows/python.yml

.openapi-generator/FILES

Lines changed: 100 additions & 23 deletions
Large diffs are not rendered by default.

.openapi-generator/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.0.0
1+
7.13.0

Pipfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,22 @@ name = "pypi"
66
[packages]
77
certifi = ">=2024.07.04"
88
six = ">=1.10"
9-
python-dateutil = ">=2.5.3"
10-
urllib3 = ">=1.26.19"
9+
python-dateutil = ">=2.8.2"
10+
urllib3 = ">=1.25.3, <3.0.0"
1111
vistir = ">=0.4.0, <=0.6.1"
1212
idna = "==3.7"
13-
requests = ">=2.32.3"
13+
requests = ">=2.32.4"
14+
pydantic = ">=2"
15+
typing-extensions = ">=4.7.1"
1416

1517
[dev-packages]
16-
setuptools = "==74.1.1"
1718
wheel = "*"
1819
twine = "*"
1920
chardet = "*"
2021
packaging = ">=22.0"
22+
types-python-dateutil = ">=2.8.19.14"
23+
mypy = ">=1.5"
24+
setuptools = "==78.1.1"
2125

2226
[requires]
23-
python_version = "3.8"
27+
python_version = "3.9"

Pipfile.lock

Lines changed: 529 additions & 274 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Regula Document Reader web API Python 3.8+ client
1+
# Regula Document Reader web API Python 3.9+ client
22

33
[![pypi](https://img.shields.io/pypi/v/regula.documentreader.webclient?style=flat-square)](https://support.regulaforensics.com/hc/en-us/articles/115000916306-Documentation)
44
[![OpenAPI](https://img.shields.io/badge/OpenAPI-defs-8c0a56?style=flat-square)](https://github.com/regulaforensics/DocumentReader-web-openapi)

dev.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
# Development
22

3-
To regenerate models, clone [latest OpenAPI definitions](https://github.com/regulaforensics/DocumentReader-web-openapi)
4-
and use next command from the project root:
3+
Models generation based on [openapi spec](https://github.com/regulaforensics/DocumentReader-api-openapi).
4+
5+
## Generation
6+
7+
To regenerate models from openapi definition,
8+
clone [latest open api definitions](https://github.com/regulaforensics/DocumentReader-api-openapi)
9+
and use next command from the project root.
510
```bash
611
./update-models.sh
712
```
13+
14+
## Generator configuration Features
15+
16+
1. When generating oneOf schemas, the generator creates its
17+
own abstract class, which does not look like it would like.
18+
The problem was solved by replacing the abstract generator
19+
class with ours using typeMappings in the generator config.
20+
2. The generator treats the discriminator value as a string,
21+
but in our case it's numbers. To solve this problem, changes
22+
have been made to the model_generic.mustache template.
23+
24+
## Problem solving
25+
26+
To solve new problems, use the generator
27+
settings ([python](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/python.md),
28+
[common](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md))
29+
and [templates](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/python).
30+
31+
**Do not edit the generated files! They will be overwritten after generation!**

example/README.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Regula Document Reader web API Python 3.5+ client
1+
# Regula Document Reader web API Python 3.9+ client
22

33
:bulb: Before you start: if you just want to play with an online demo, visit our [playground](https://api.regulaforensics.com).
44

@@ -10,15 +10,15 @@ you agree with our [Privacy Policy](https://regulaforensics.com/en/company/priva
1010
and [License Agreement](https://downloads.regulaforensics.com/work/SDK/doc/Eula.pdf).
1111

1212
Requirements:
13-
- installed python 3.5 or higher
13+
- installed python 3.9 or higher
1414
- installed [pip](https://pip.pypa.io/en/stable/installing/)
1515

1616
Verify Python and pip versions:
1717
```bash
1818
python --version
19-
> Python 3.8.2
19+
> Python 3.9.2
2020
pip --version
21-
> pip 20.2.1 from /home/user/.local/lib/python3.8/site-packages/pip (python 3.8)
21+
> pip 22.0.4 from /home/user/.local/lib/python3.9/site-packages/pip (python 3.9)
2222
```
2323

2424
Cloning example:
@@ -54,16 +54,29 @@ API_BASE_PATH="http://127.0.0.1:8080" python example.py
5454
```
5555

5656
### Output
57+
5758
This sample generates the following text output:
59+
5860
```text
5961
---------------------------------------------------------------------------
60-
Document Overall Status: not valid
61-
Document Number Visual: OO0000000
62-
Document Number MRZ: OO0000000
63-
Validity Of Document Number Visual: 0
64-
Validity Of Document Number MRZ: 0
65-
MRZ-Visual values comparison: 1
62+
Web API version: 7.5.308602.1848
6663
---------------------------------------------------------------------------
64+
Document Overall Status: not valid
65+
Document Number Visual: C01YPTNHM
66+
Document Type: Germany - ePassport (2017) Service
67+
Validity Of Document Number Visual: 2
68+
69+
-----------------------All Text Fields------------------------
70+
Source: Surname, Value: MUSTERMANN
71+
Source: Surname And Given Names, Value: MUSTERMANN ERIKA
72+
Source: Document Status, Value: SPECIMEN
73+
Source: Surname, Value: MUSTERMANN
74+
Source: Surname And Given Names, Value: MUSTERMANN ERIKA
75+
Source: Document Number Checkdigit, Value: 1
76+
Source: Document Class Code, Value: PO
77+
78+
...
6779
```
80+
6881
Also, it stores [portrait](portrait.jpg) and [document image](document-image.jpg) images in the current folder.
6982
You can modify [this example](../example/example.py) and re-run it to get your own results.

example/encrypted-rcl.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

example/example-rcl.py

Lines changed: 0 additions & 99 deletions
This file was deleted.

example/example.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44

55
host = os.getenv("API_BASE_PATH", "https://api.regulaforensics.com")
66

7-
# read optional local license file
8-
if os.path.isfile('regula.license') and os.access('regula.license', os.R_OK):
9-
with open("regula.license", "rb") as f:
10-
print("Found local license file. Using it for performing request...")
11-
regula_license = f.read()
12-
137
with open("WHITE.jpg", "rb") as f:
148
white_page_0 = f.read()
159

@@ -24,12 +18,7 @@
2418
"X-CLIENT-KEY": "123",
2519
"Authorization": "Bearer 123"
2620
}
27-
params = ProcessParams(already_cropped=True, scenario=Scenario.FULL_PROCESS)
28-
29-
# Add license to request
30-
# request = RecognitionRequest(system_info=ProcessSystemInfo(license=base64.b64encode(regula_license).decode()), process_params=params, images=[
31-
# RecognitionImage(image=white_page_0, light_index=Light.WHITE, page_index=0),
32-
# ])
21+
params = ProcessParams(alreadyCropped=True, scenario=Scenario.FULL_PROCESS)
3322

3423
request = RecognitionRequest(process_params=params, images=[
3524
RecognitionImage(image=white_page_0, light_index=Light.WHITE, page_index=0),
@@ -38,8 +27,8 @@
3827
])
3928
response = api.process(request)
4029

41-
request_json = request.json # example for request & response raw json
42-
response_json = response.json
30+
request_json = request.to_json() # example for request & response raw json
31+
response_json = response.to_json()
4332

4433
# status examples
4534
response_status = response.status
@@ -63,13 +52,13 @@
6352
# if FULL_PROCESS then auth is None
6453

6554
doc_ir_b900_blank = doc_ir_b900.checks_by_element(SecurityFeatureType.BLANK) \
66-
if doc_authenticity is not None else None
55+
if doc_ir_b900 is not None else None
6756

6857
doc_image_pattern = doc_authenticity.image_pattern_checks \
6958
if doc_authenticity is not None else None
7059

7160
doc_image_pattern_blank = doc_image_pattern.checks_by_element(SecurityFeatureType.BLANK) \
72-
if doc_authenticity is not None else None
61+
if doc_image_pattern is not None else None
7362

7463
# images fields example
7564
document_image = response.images.get_field(GraphicFieldType.DOCUMENT_FRONT).get_value()

example/license.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

generator-config.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
{
22
"packageName": "regula.documentreader.webclient.gen",
3-
"extPackageName": "regula.documentreader.webclient.ext"
3+
"extPackageName": "regula.documentreader.webclient.ext",
4+
"typeMappings" : {
5+
"ContainerListListInner": "ResultItem",
6+
"AuthenticityCheckResultListInner": "AuthenticityCheckResultItem"
7+
}
48
}

0 commit comments

Comments
 (0)