Skip to content

Commit

Permalink
SP-19086 add custom headers example
Browse files Browse the repository at this point in the history
  • Loading branch information
KirylKovaliov committed Nov 1, 2024
1 parent 94bae3e commit d009779
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 46 deletions.
3 changes: 0 additions & 3 deletions .openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,3 @@ README.md
.gitignore
setup.py
regula/documentreader/webclient/__init__.py

regula/documentreader/webclient/gen/models/container_list.py
regula/documentreader/webclient/gen/models/authenticity_check_result.py
2 changes: 2 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ regula/documentreader/webclient/gen/models/area_array.py
regula/documentreader/webclient/gen/models/area_container.py
regula/documentreader/webclient/gen/models/auth_params.py
regula/documentreader/webclient/gen/models/authenticity_check_list.py
regula/documentreader/webclient/gen/models/authenticity_check_result.py
regula/documentreader/webclient/gen/models/authenticity_check_result_item.py
regula/documentreader/webclient/gen/models/authenticity_result.py
regula/documentreader/webclient/gen/models/authenticity_result_all_of.py
Expand All @@ -24,6 +25,7 @@ regula/documentreader/webclient/gen/models/check_result.py
regula/documentreader/webclient/gen/models/chosen_document_type.py
regula/documentreader/webclient/gen/models/chosen_document_type_result.py
regula/documentreader/webclient/gen/models/chosen_document_type_result_all_of.py
regula/documentreader/webclient/gen/models/container_list.py
regula/documentreader/webclient/gen/models/critical.py
regula/documentreader/webclient/gen/models/cross_source_value_comparison.py
regula/documentreader/webclient/gen/models/data_module.py
Expand Down
5 changes: 4 additions & 1 deletion example/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@

with DocumentReaderApi(host) as api:
api.license = regula_license

api.api_client.default_headers = {
"X-CLIENT-KEY": "123",
"Authorization": "Bearer 123"
}
params = ProcessParams(
scenario=Scenario.FULL_PROCESS,
result_type_output=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from regula.documentreader.webclient.gen.models import *


"""
"""
class AuthenticityCheckResult(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Expand All @@ -29,7 +32,7 @@ class AuthenticityCheckResult(object):
and the value is json key in definition.
"""
openapi_types = {
'type': 'SecurityFeatureType',
'type': 'AuthenticityResultType',
'result': 'CheckResult',
'list': 'list[AuthenticityCheckResultItem]'
}
Expand Down Expand Up @@ -61,7 +64,7 @@ def type(self):
:return: The type of this AuthenticityCheckResult. # noqa: E501
:rtype: SecurityFeatureType
:rtype: AuthenticityResultType
"""
return self._type

Expand All @@ -71,7 +74,7 @@ def type(self, type):
:param type: The type of this AuthenticityCheckResult. # noqa: E501
:type type: SecurityFeatureType
:type type: AuthenticityResultType
"""
if self.local_vars_configuration.client_side_validation and type is None: # noqa: E501
raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501
Expand Down
45 changes: 36 additions & 9 deletions regula/documentreader/webclient/gen/models/container_list.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# coding: utf-8

"""
Regula Document Reader Web API
Regula Document Reader Web API # noqa: E501
The version of the OpenAPI document: 5.1.0
Generated by: https://openapi-generator.tech
"""


import pprint
import re # noqa: F401

import six

from regula.documentreader.webclient.gen.configuration import Configuration
# this line was added to enable pycharm type hinting
from regula.documentreader.webclient.gen.models import *


"""
List with various objects, containing processing results
"""
class ContainerList(object):
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Expand All @@ -33,31 +32,59 @@ class ContainerList(object):
and the value is json key in definition.
"""
openapi_types = {
'count': 'int',
'list': 'list[ResultItem]'
}

attribute_map = {
'count': 'Count',
'list': 'List'
}

def __init__(self, list=None, local_vars_configuration=None): # noqa: E501
def __init__(self, count=None, list=None, local_vars_configuration=None): # noqa: E501
"""ContainerList - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
self.local_vars_configuration = local_vars_configuration

self._count = None
self._list = None
self.discriminator = None

if count is not None:
self.count = count
self.list = list

@property
def count(self):
"""Gets the count of this ContainerList. # noqa: E501
Length of list (Count for items) # noqa: E501
:return: The count of this ContainerList. # noqa: E501
:rtype: int
"""
return self._count

@count.setter
def count(self, count):
"""Sets the count of this ContainerList.
Length of list (Count for items) # noqa: E501
:param count: The count of this ContainerList. # noqa: E501
:type count: int
"""

self._count = count

@property
def list(self):
"""Gets the list of this ContainerList. # noqa: E501
:return: The list of this ContainerList. # noqa: E501
:rtype: list[AnyOfRawImageResultTextResultStatusResultTextDataResultGraphicsResultLexicalAnalysisResultChosenDocumentTypeResultDocumentTypesCandidatesResultImagesResult]
:rtype: list[ResultItem]
"""
return self._list

Expand All @@ -67,7 +94,7 @@ def list(self, list):
:param list: The list of this ContainerList. # noqa: E501
:type list: list[AnyOfRawImageResultTextResultStatusResultTextDataResultGraphicsResultLexicalAnalysisResultChosenDocumentTypeResultDocumentTypesCandidatesResultImagesResult]
:type list: list[ResultItem]
"""
if self.local_vars_configuration.client_side_validation and list is None: # noqa: E501
raise ValueError("Invalid value for `list`, must not be `None`") # noqa: E501
Expand Down
30 changes: 1 addition & 29 deletions regula/documentreader/webclient/gen/models/process_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class ProcessParams(object):
'return_uncropped_image': 'bool',
'mrz_formats_filter': 'list[MRZFormat]',
'force_read_mrz_before_locate': 'bool',
'force_barcode_checks': 'bool',
'parse_barcodes': 'bool',
'convert_case': 'TextPostProcessing',
'split_names': 'bool',
Expand Down Expand Up @@ -128,7 +127,6 @@ class ProcessParams(object):
'return_uncropped_image': 'returnUncroppedImage',
'mrz_formats_filter': 'mrzFormatsFilter',
'force_read_mrz_before_locate': 'forceReadMrzBeforeLocate',
'force_barcode_checks': 'forceBarcodeChecks',
'parse_barcodes': 'parseBarcodes',
'convert_case': 'convertCase',
'split_names': 'splitNames',
Expand All @@ -147,7 +145,7 @@ class ProcessParams(object):
'generate_numeric_codes': 'generateNumericCodes'
}

def __init__(self, lcid_filter=None, lcid_ignore_filter=None, one_shot_identification=None, use_face_api=None, face_api=None, do_detect_can=None, image_output_max_height=None, image_output_max_width=None, scenario=None, result_type_output=None, double_page_spread=None, generate_double_page_spread_image=None, field_types_filter=None, date_format=None, measure_system=None, image_dpi_out_max=None, already_cropped=None, custom_params=None, config=None, log=None, log_level=None, force_doc_id=None, match_text_field_mask=None, fast_doc_detect=None, update_ocr_validity_by_glare=None, check_required_text_fields=None, return_cropped_barcode=None, image_qa=None, respect_image_quality=None, force_doc_format=None, no_graphics=None, depersonalize_log=None, multi_doc_on_image=None, shift_expiry_date=None, minimal_holder_age=None, return_uncropped_image=None, mrz_formats_filter=None, force_read_mrz_before_locate=None, force_barcode_checks=None, parse_barcodes=None, convert_case=None, split_names=None, disable_perforation_ocr=None, document_group_filter=None, process_auth=None, device_id=None, device_type=None, device_type_hex=None, ignore_device_id_from_image=None, document_id_list=None, rfid=None, check_auth=None, auth_params=None, mrz_detect_mode=None, generate_numeric_codes=None, local_vars_configuration=None): # noqa: E501
def __init__(self, lcid_filter=None, lcid_ignore_filter=None, one_shot_identification=None, use_face_api=None, face_api=None, do_detect_can=None, image_output_max_height=None, image_output_max_width=None, scenario=None, result_type_output=None, double_page_spread=None, generate_double_page_spread_image=None, field_types_filter=None, date_format=None, measure_system=None, image_dpi_out_max=None, already_cropped=None, custom_params=None, config=None, log=None, log_level=None, force_doc_id=None, match_text_field_mask=None, fast_doc_detect=None, update_ocr_validity_by_glare=None, check_required_text_fields=None, return_cropped_barcode=None, image_qa=None, respect_image_quality=None, force_doc_format=None, no_graphics=None, depersonalize_log=None, multi_doc_on_image=None, shift_expiry_date=None, minimal_holder_age=None, return_uncropped_image=None, mrz_formats_filter=None, force_read_mrz_before_locate=None, parse_barcodes=None, convert_case=None, split_names=None, disable_perforation_ocr=None, document_group_filter=None, process_auth=None, device_id=None, device_type=None, device_type_hex=None, ignore_device_id_from_image=None, document_id_list=None, rfid=None, check_auth=None, auth_params=None, mrz_detect_mode=None, generate_numeric_codes=None, local_vars_configuration=None): # noqa: E501
"""ProcessParams - a model defined in OpenAPI""" # noqa: E501
if local_vars_configuration is None:
local_vars_configuration = Configuration()
Expand Down Expand Up @@ -191,7 +189,6 @@ def __init__(self, lcid_filter=None, lcid_ignore_filter=None, one_shot_identific
self._return_uncropped_image = None
self._mrz_formats_filter = None
self._force_read_mrz_before_locate = None
self._force_barcode_checks = None
self._parse_barcodes = None
self._convert_case = None
self._split_names = None
Expand Down Expand Up @@ -285,8 +282,6 @@ def __init__(self, lcid_filter=None, lcid_ignore_filter=None, one_shot_identific
self.mrz_formats_filter = mrz_formats_filter
if force_read_mrz_before_locate is not None:
self.force_read_mrz_before_locate = force_read_mrz_before_locate
if force_barcode_checks is not None:
self.force_barcode_checks = force_barcode_checks
if parse_barcodes is not None:
self.parse_barcodes = parse_barcodes
if convert_case is not None:
Expand Down Expand Up @@ -1184,29 +1179,6 @@ def force_read_mrz_before_locate(self, force_read_mrz_before_locate):

self._force_read_mrz_before_locate = force_read_mrz_before_locate

@property
def force_barcode_checks(self):
"""Gets the force_barcode_checks of this ProcessParams. # noqa: E501
Allows you to fail both the Barcode format check and overall statuses of the document if the Digital signature check is not performed # noqa: E501
:return: The force_barcode_checks of this ProcessParams. # noqa: E501
:rtype: bool
"""
return self._force_barcode_checks

@force_barcode_checks.setter
def force_barcode_checks(self, force_barcode_checks):
"""Sets the force_barcode_checks of this ProcessParams.
Allows you to fail both the Barcode format check and overall statuses of the document if the Digital signature check is not performed # noqa: E501
:param force_barcode_checks: The force_barcode_checks of this ProcessParams. # noqa: E501
:type force_barcode_checks: bool
"""

self._force_barcode_checks = force_barcode_checks

@property
def parse_barcodes(self):
"""Gets the parse_barcodes of this ProcessParams. # noqa: E501
Expand Down
7 changes: 6 additions & 1 deletion update-models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ DOCS_DEFINITION_FOLDER="${PWD}/../DocumentReader-web-openapi" \
&& docker run --user "$(id -u):$(id -g)" --rm -v "${PWD}:/client" -v "$DOCS_DEFINITION_FOLDER:/definitions" \
openapitools/openapi-generator-cli:v5.0.0 generate -g python-legacy \
-i /definitions/index.yml -o /client -c /client/generator-config.json \
-t /client/generator-templates
-t /client/generator-templates \
--type-mappings AnyOfDocVisualExtendedFieldRectDocVisualExtendedFieldRfid=DocVisualExtendedField \
--type-mappings AnyOfSecurityFeatureResultIdentResultFiberResultOCRSecurityTextResultPhotoIdentResult=AuthenticityCheckResultItem \
--type-mappings AnyOfGraphicFieldRectGraphicFieldRfid=GraphicField \
--type-mappings AnyOfStatusResultTextResultDocumentImageResultImagesResultChosenDocumentTypeResultDocumentTypesCandidatesResultTextDataResultGraphicsResultLexicalAnalysisResultAuthenticityResultImageQualityResultDocumentPositionResultDocBarCodeInfoLicenseResultEncryptedRCLResultDocumentBinaryInfoResult=ResultItem \
--type-mappings AnyOfStatusResultTextResultDocumentImageResultImagesResultChosenDocumentTypeResultDocumentTypesCandidatesResultTextDataResultGraphicsResultLexicalAnalysisResultAuthenticityResultImageQualityResultDocumentPositionResultDocBarCodeInfoLicenseResultEncryptedRCLResult=ResultItem

0 comments on commit d009779

Please sign in to comment.