Skip to content

NEW GENERATOR #188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ README.md
.gitignore
setup.py
regula/documentreader/webclient/__init__.py
pyproject.toml
.github/workflows/python.yml
122 changes: 99 additions & 23 deletions .openapi-generator/FILES

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .openapi-generator/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.0
7.12.0
8 changes: 6 additions & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,22 @@ name = "pypi"
[packages]
certifi = ">=2024.07.04"
six = ">=1.10"
python-dateutil = ">=2.5.3"
urllib3 = ">=1.26.19"
python-dateutil = ">=2.8.2"
urllib3 = ">=1.25.3, <3.0.0"
vistir = ">=0.4.0, <=0.6.1"
idna = "==3.7"
requests = ">=2.32.3"
pydantic = ">=2"
typing-extensions = ">=4.7.1"

[dev-packages]
setuptools = "==74.1.1"
wheel = "*"
twine = "*"
chardet = "*"
packaging = ">=22.0"
types-python-dateutil = ">=2.8.19.14"
mypy = ">=1.5"

[requires]
python_version = "3.8"
758 changes: 506 additions & 252 deletions Pipfile.lock

Large diffs are not rendered by default.

28 changes: 26 additions & 2 deletions dev.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
# Development

To regenerate models, clone [latest OpenAPI definitions](https://github.com/regulaforensics/DocumentReader-web-openapi)
and use next command from the project root:
Models generation based on [openapi spec](https://github.com/regulaforensics/DocumentReader-api-openapi).

## Generation

To regenerate models from openapi definition,
clone [latest open api definitions](https://github.com/regulaforensics/DocumentReader-api-openapi)
and use next command from the project root.
```bash
./update-models.sh
```

## Generator configuration Features

1. When generating oneOf schemas, the generator creates its
own abstract class, which does not look like it would like.
The problem was solved by replacing the abstract generator
class with ours using typeMappings in the generator config.
2. The generator treats the discriminator value as a string,
but in our case it's numbers. To solve this problem, changes
have been made to the model_generic.mustache template.

## Problem solving

To solve new problems, use the generator
settings ([python](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/python.md),
[common](https://github.com/OpenAPITools/openapi-generator/blob/master/docs/customization.md))
and [templates](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/python).

**Do not edit the generated files! They will be overwritten after generation!**
25 changes: 19 additions & 6 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,29 @@ API_BASE_PATH="http://127.0.0.1:8080" python example.py
```

### Output

This sample generates the following text output:

```text
---------------------------------------------------------------------------
Document Overall Status: not valid
Document Number Visual: OO0000000
Document Number MRZ: OO0000000
Validity Of Document Number Visual: 0
Validity Of Document Number MRZ: 0
MRZ-Visual values comparison: 1
Web API version: 7.5.308602.1848
---------------------------------------------------------------------------
Document Overall Status: not valid
Document Number Visual: C01YPTNHM
Document Type: Germany - ePassport (2017) Service
Validity Of Document Number Visual: 2

-----------------------All Text Fields------------------------
Source: Surname, Value: MUSTERMANN
Source: Surname And Given Names, Value: MUSTERMANN ERIKA
Source: Document Status, Value: SPECIMEN
Source: Surname, Value: MUSTERMANN
Source: Surname And Given Names, Value: MUSTERMANN ERIKA
Source: Document Number Checkdigit, Value: 1
Source: Document Class Code, Value: PO

...
```

Also, it stores [portrait](portrait.jpg) and [document image](document-image.jpg) images in the current folder.
You can modify [this example](../example/example.py) and re-run it to get your own results.
1 change: 0 additions & 1 deletion example/encrypted-rcl.txt

This file was deleted.

99 changes: 0 additions & 99 deletions example/example-rcl.py

This file was deleted.

6 changes: 3 additions & 3 deletions example/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"X-CLIENT-KEY": "123",
"Authorization": "Bearer 123"
}
params = ProcessParams(already_cropped=True, scenario=Scenario.FULL_PROCESS)
params = ProcessParams(alreadyCropped=True, scenario=Scenario.FULLPROCESS)

# Add license to request
# request = RecognitionRequest(system_info=ProcessSystemInfo(license=base64.b64encode(regula_license).decode()), process_params=params, images=[
Expand All @@ -38,8 +38,8 @@
])
response = api.process(request)

request_json = request.json # example for request & response raw json
response_json = response.json
request_json = request.to_json() # example for request & response raw json
response_json = response.to_json()

# status examples
response_status = response.status
Expand Down
1 change: 0 additions & 1 deletion example/license.txt

This file was deleted.

6 changes: 5 additions & 1 deletion generator-config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"packageName": "regula.documentreader.webclient.gen",
"extPackageName": "regula.documentreader.webclient.ext"
"extPackageName": "regula.documentreader.webclient.ext",
"typeMappings" : {
"ContainerListListInner": "ResultItem",
"AuthenticityCheckResultListInner": "AuthenticityCheckResultItem"
}
}
Loading