From 12f0da304c1cee65aac545ff79a5ef9debf80717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <h.tomwoerden@indiscale.com> Date: Tue, 17 Oct 2023 11:08:47 +0200 Subject: [PATCH] MAINT: Revert part of the refactoring --- .../bloxberg/swagger_client/__init__.py | 21 ++++++++++--------- .../bloxberg/swagger_client/api_client.py | 2 +- .../bloxberg/swagger_client/models/batch.py | 1 + ...ert_tools_generate_pdf_json_certificate.py | 1 + ...e_unsigned_certificate_json_certificate.py | 1 + .../models/http_validation_error.py | 1 + .../swagger_client/models/validation_error.py | 1 + src/caosadvancedtools/json_schema_exporter.py | 18 +++++++--------- 8 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/caosadvancedtools/bloxberg/swagger_client/__init__.py b/src/caosadvancedtools/bloxberg/swagger_client/__init__.py index 136c5b27..255d6d31 100644 --- a/src/caosadvancedtools/bloxberg/swagger_client/__init__.py +++ b/src/caosadvancedtools/bloxberg/swagger_client/__init__.py @@ -13,22 +13,23 @@ """ from __future__ import absolute_import +from swagger_client.models.validation_error import ValidationError +from swagger_client.models.http_validation_error import HTTPValidationError +from swagger_client.models.controller_cert_tools_generate_unsigned_certificate_json_certificate import ControllerCertToolsGenerateUnsignedCertificateJsonCertificate +from swagger_client.models.controller_cert_tools_generate_pdf_json_certificate import ControllerCertToolsGeneratePdfJsonCertificate +from swagger_client.models.batch import Batch +from swagger_client.configuration import Configuration +from swagger_client.api_client import ApiClient +from swagger_client.api.pdf_api import PdfApi +from swagger_client.api.certificate_api import CertificateApi # Fake the installation -import sys, pathlib +import sys +import pathlib __this_dir = str(pathlib.Path(__file__).parent.parent) if __this_dir not in sys.path: sys.path.append(__this_dir) # import apis into sdk package -from swagger_client.api.certificate_api import CertificateApi -from swagger_client.api.pdf_api import PdfApi # import ApiClient -from swagger_client.api_client import ApiClient -from swagger_client.configuration import Configuration # import models into sdk package -from swagger_client.models.batch import Batch -from swagger_client.models.controller_cert_tools_generate_pdf_json_certificate import ControllerCertToolsGeneratePdfJsonCertificate -from swagger_client.models.controller_cert_tools_generate_unsigned_certificate_json_certificate import ControllerCertToolsGenerateUnsignedCertificateJsonCertificate -from swagger_client.models.http_validation_error import HTTPValidationError -from swagger_client.models.validation_error import ValidationError diff --git a/src/caosadvancedtools/bloxberg/swagger_client/api_client.py b/src/caosadvancedtools/bloxberg/swagger_client/api_client.py index 25e6501a..7337ca33 100644 --- a/src/caosadvancedtools/bloxberg/swagger_client/api_client.py +++ b/src/caosadvancedtools/bloxberg/swagger_client/api_client.py @@ -591,7 +591,7 @@ class ApiClient(object): ) def __hasattr(self, object, name): - return name in object.__class__.__dict__ + return name in object.__class__.__dict__ def __deserialize_model(self, data, klass): """Deserializes list or dict to model. diff --git a/src/caosadvancedtools/bloxberg/swagger_client/models/batch.py b/src/caosadvancedtools/bloxberg/swagger_client/models/batch.py index 7a347cf7..474ca01a 100644 --- a/src/caosadvancedtools/bloxberg/swagger_client/models/batch.py +++ b/src/caosadvancedtools/bloxberg/swagger_client/models/batch.py @@ -15,6 +15,7 @@ import re # noqa: F401 import six + class Batch(object): """NOTE: This class is auto generated by the swagger code generator program. diff --git a/src/caosadvancedtools/bloxberg/swagger_client/models/controller_cert_tools_generate_pdf_json_certificate.py b/src/caosadvancedtools/bloxberg/swagger_client/models/controller_cert_tools_generate_pdf_json_certificate.py index 2d7fd2d7..8c1b50d8 100644 --- a/src/caosadvancedtools/bloxberg/swagger_client/models/controller_cert_tools_generate_pdf_json_certificate.py +++ b/src/caosadvancedtools/bloxberg/swagger_client/models/controller_cert_tools_generate_pdf_json_certificate.py @@ -15,6 +15,7 @@ import re # noqa: F401 import six + class ControllerCertToolsGeneratePdfJsonCertificate(object): """NOTE: This class is auto generated by the swagger code generator program. diff --git a/src/caosadvancedtools/bloxberg/swagger_client/models/controller_cert_tools_generate_unsigned_certificate_json_certificate.py b/src/caosadvancedtools/bloxberg/swagger_client/models/controller_cert_tools_generate_unsigned_certificate_json_certificate.py index 4a6d2d3f..fa0da3cb 100644 --- a/src/caosadvancedtools/bloxberg/swagger_client/models/controller_cert_tools_generate_unsigned_certificate_json_certificate.py +++ b/src/caosadvancedtools/bloxberg/swagger_client/models/controller_cert_tools_generate_unsigned_certificate_json_certificate.py @@ -15,6 +15,7 @@ import re # noqa: F401 import six + class ControllerCertToolsGenerateUnsignedCertificateJsonCertificate(object): """NOTE: This class is auto generated by the swagger code generator program. diff --git a/src/caosadvancedtools/bloxberg/swagger_client/models/http_validation_error.py b/src/caosadvancedtools/bloxberg/swagger_client/models/http_validation_error.py index 21c9e467..67c23fba 100644 --- a/src/caosadvancedtools/bloxberg/swagger_client/models/http_validation_error.py +++ b/src/caosadvancedtools/bloxberg/swagger_client/models/http_validation_error.py @@ -15,6 +15,7 @@ import re # noqa: F401 import six + class HTTPValidationError(object): """NOTE: This class is auto generated by the swagger code generator program. diff --git a/src/caosadvancedtools/bloxberg/swagger_client/models/validation_error.py b/src/caosadvancedtools/bloxberg/swagger_client/models/validation_error.py index 7ae6bf09..96d1e237 100644 --- a/src/caosadvancedtools/bloxberg/swagger_client/models/validation_error.py +++ b/src/caosadvancedtools/bloxberg/swagger_client/models/validation_error.py @@ -15,6 +15,7 @@ import re # noqa: F401 import six + class ValidationError(object): """NOTE: This class is auto generated by the swagger code generator program. diff --git a/src/caosadvancedtools/json_schema_exporter.py b/src/caosadvancedtools/json_schema_exporter.py index 58c09672..68b4e5bc 100644 --- a/src/caosadvancedtools/json_schema_exporter.py +++ b/src/caosadvancedtools/json_schema_exporter.py @@ -24,7 +24,7 @@ import re from typing import Optional import linkahead as db -from linkahead.common.datatype import is_list_datatype, get_list_datatype +from linkahead.common.datatype import get_list_datatype, is_list_datatype def _make_required_list(rt: db.RecordType): @@ -41,7 +41,7 @@ def _make_prop_from_prop(prop: db.Property, additional_options_for_text_props: O prop : db.Property the property to be transformed additional_options_for_text_props : Optional[dict] - dict that may contain the keys 'pattern' and 'format' to + dict of dicts that may contain the keys 'pattern' and 'format' to further define the rules for the JSON Schema segment """ @@ -53,11 +53,11 @@ def _make_prop_from_prop(prop: db.Property, additional_options_for_text_props: O if prop.datatype == db.TEXT or prop.datatype == db.DATETIME: text_format = None text_pattern = None - if additional_options_for_text_props: - if "pattern" in additional_options_for_text_props: - text_pattern = additional_options_for_text_props["pattern"] - if "format" in additional_options_for_text_props: - text_format = additional_options_for_text_props["format"] + if prop.name in additional_options_for_text_props: + if "pattern" in additional_options_for_text_props[prop.name]: + text_pattern = additional_options_for_text_props[prop.name]["pattern"] + if "format" in additional_options_for_text_props[prop.name]: + text_format = additional_options_for_text_props[prop.name]["format"] elif prop.datatype == db.DATETIME: # Set the date or datetime format if only a pattern is given ... text_format = ["date", "date-time"] @@ -163,9 +163,7 @@ def recordtype_to_json_schema(rt: db.RecordType, additional_properties: bool = T "Creating a schema for multi-properties is not specified. " f"Property {prop.name} occurs more than once." ) - props[prop.name] = _make_prop_from_prop(prop, additional_options_for_text_props[prop.name] - if prop.name in additional_options_for_text_props - else None) + props[prop.name] = _make_prop_from_prop(prop, additional_options_for_text_props) schema["properties"] = props return schema -- GitLab