Skip to content

Commit 1b37c28

Browse files
authored
fix: Incorrect typings from OpenAPI spec (#6)
1 parent b7c236a commit 1b37c28

14 files changed

+43
-46
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Please, include the `User-Agent` header with the name of your application or pro
1313
This Python package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
1414

1515
- API version: Latest
16-
- Package version: 0.3.1
16+
- Package version: 0.3.2
1717
- Build package: org.openapitools.codegen.languages.PythonClientCodegen
1818

1919
## Requirements.

docs/MTSettingsPerLanguageDto.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
| Name | Type | Description | Notes |
66
| ------------------------------ | ----------------------------------------------------------------- | ------------------------------------------------------------------- | ---------- |
7-
| **target_lang** | **str** | mtSettings is set for whole project if targetLang == null |
7+
| **target_lang** | **str** | mtSettings is set for whole project if targetLang == null | [optional] |
88
| **machine_translate_settings** | [**MachineTranslateSettingsDto**](MachineTranslateSettingsDto.md) | | [optional] |
99

1010
## Example

docs/MTSettingsPerLanguageReference.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
| Name | Type | Description | Notes |
66
| ------------------------------ | ----------------------------------------------------------------------------- | ------------------------------------------------------------------- | ---------- |
7-
| **target_lang** | **str** | mtSettings is set for whole project if targetLang == null |
7+
| **target_lang** | **str** | mtSettings is set for whole project if targetLang == null | [optional] |
88
| **machine_translate_settings** | [**MachineTranslateSettingsReference**](MachineTranslateSettingsReference.md) | | [optional] |
99

1010
## Example

phrasetms_client/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"""
1515

1616

17-
__version__ = "0.3.1"
17+
__version__ = "0.3.2"
1818

1919
# import apis into sdk package
2020
from phrasetms_client.api.additional_workflow_step_api import AdditionalWorkflowStepApi

phrasetms_client/api/job_api.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ def copy_source_to_target_job_part_with_http_info(self, project_uid : StrictStr,
701701
_request_auth=_params.get('_request_auth'))
702702

703703
@validate_arguments
704-
def create_job(self, project_uid : StrictStr, memsource : Optional[StrictStr] = None, content_disposition : Annotated[Optional[StrictStr], Field(description="must match pattern `((inline|attachment); )?(filename\\*=UTF-8''(.+)|filename=\"?(.+)\"?)`")] = None, body : Optional[Dict[str, Any]] = None, **kwargs) -> JobListDto: # noqa: E501
704+
def create_job(self, project_uid : StrictStr, memsource : Optional[StrictStr] = None, content_disposition : Annotated[Optional[StrictStr], Field(description="must match pattern `((inline|attachment); )?(filename\\*=UTF-8''(.+)|filename=\"?(.+)\"?)`")] = None, body : Optional[object] = None, **kwargs) -> JobListDto: # noqa: E501
705705
"""Create job # noqa: E501
706706
707707
Job file can be provided directly in the message body or downloaded from connector. Please supply job metadata in `Memsource` header. For file in the request body provide also the filename in `Content-Disposition` header. Accepted metadata: - `targetLangs` - **required** - `due` - ISO 8601 - `workflowSettings` - project with workflow - see examples bellow - `assignments` - project without workflows - see examples bellow - `importSettings` - re-usable import settings - see [Create import settings](#operation/createImportSettings) - `useProjectFileImportSettings` - mutually exclusive with importSettings - `callbackUrl` - consumer callback - `path` - original destination directory - `preTranslate` - set pre translate job after import for remote file jobs also `remoteFile` - see examples bellow: - `connectorToken` - remote connector token - `remoteFolder` - `remoteFileName` - `continuous` - true for continuous job Create and assign job in project without workflow step: ``` { \"targetLangs\": [ \"cs_cz\" ], \"callbackUrl\": \"https://my-shiny-service.com/consumeCallback\", \"importSettings\": { \"uid\": \"abcd123\" }, \"due\": \"2007-12-03T10:15:30.00Z\", \"path\": \"destination directory\", \"assignments\": [ { \"targetLang\": \"cs_cz\", \"providers\": [ { \"id\": \"4321\", \"type\": \"USER\" } ] } ], \"notifyProvider\": { \"organizationEmailTemplate\": { \"id\": \"39\" }, \"notificationIntervalInMinutes\": \"10\" } } ``` Create job from remote file without workflow steps: ``` { \"remoteFile\": { \"connectorToken\": \"948123ef-e1ef-4cd3-a90e-af1617848af3\", \"remoteFolder\": \"/\", \"remoteFileName\": \"Few words.docx\", \"continuous\": false }, \"assignments\": [], \"workflowSettings\": [], \"targetLangs\": [ \"cs\" ] } ``` Create and assign job in project with workflow step: ``` { \"targetLangs\": [ \"de\" ], \"useProjectFileImportSettings\": \"true\", \"workflowSettings\": [ { \"id\": \"64\", \"due\": \"2007-12-03T10:15:30.00Z\", \"assignments\": [ { \"targetLang\": \"de\", \"providers\": [ { \"id\": \"3\", \"type\": \"VENDOR\" } ] } ], \"notifyProvider\": { \"organizationEmailTemplate\": { \"id\": \"39\" }, \"notificationIntervalInMinutes\": \"10\" } } ] } ``` # noqa: E501
@@ -736,7 +736,7 @@ def create_job(self, project_uid : StrictStr, memsource : Optional[StrictStr] =
736736
return self.create_job_with_http_info(project_uid, memsource, content_disposition, body, **kwargs) # noqa: E501
737737

738738
@validate_arguments
739-
def create_job_with_http_info(self, project_uid : StrictStr, memsource : Optional[StrictStr] = None, content_disposition : Annotated[Optional[StrictStr], Field(description="must match pattern `((inline|attachment); )?(filename\\*=UTF-8''(.+)|filename=\"?(.+)\"?)`")] = None, body : Optional[Dict[str, Any]] = None, **kwargs) -> ApiResponse: # noqa: E501
739+
def create_job_with_http_info(self, project_uid : StrictStr, memsource : Optional[StrictStr] = None, content_disposition : Annotated[Optional[StrictStr], Field(description="must match pattern `((inline|attachment); )?(filename\\*=UTF-8''(.+)|filename=\"?(.+)\"?)`")] = None, body : Optional[object] = None, **kwargs) -> ApiResponse: # noqa: E501
740740
"""Create job # noqa: E501
741741
742742
Job file can be provided directly in the message body or downloaded from connector. Please supply job metadata in `Memsource` header. For file in the request body provide also the filename in `Content-Disposition` header. Accepted metadata: - `targetLangs` - **required** - `due` - ISO 8601 - `workflowSettings` - project with workflow - see examples bellow - `assignments` - project without workflows - see examples bellow - `importSettings` - re-usable import settings - see [Create import settings](#operation/createImportSettings) - `useProjectFileImportSettings` - mutually exclusive with importSettings - `callbackUrl` - consumer callback - `path` - original destination directory - `preTranslate` - set pre translate job after import for remote file jobs also `remoteFile` - see examples bellow: - `connectorToken` - remote connector token - `remoteFolder` - `remoteFileName` - `continuous` - true for continuous job Create and assign job in project without workflow step: ``` { \"targetLangs\": [ \"cs_cz\" ], \"callbackUrl\": \"https://my-shiny-service.com/consumeCallback\", \"importSettings\": { \"uid\": \"abcd123\" }, \"due\": \"2007-12-03T10:15:30.00Z\", \"path\": \"destination directory\", \"assignments\": [ { \"targetLang\": \"cs_cz\", \"providers\": [ { \"id\": \"4321\", \"type\": \"USER\" } ] } ], \"notifyProvider\": { \"organizationEmailTemplate\": { \"id\": \"39\" }, \"notificationIntervalInMinutes\": \"10\" } } ``` Create job from remote file without workflow steps: ``` { \"remoteFile\": { \"connectorToken\": \"948123ef-e1ef-4cd3-a90e-af1617848af3\", \"remoteFolder\": \"/\", \"remoteFileName\": \"Few words.docx\", \"continuous\": false }, \"assignments\": [], \"workflowSettings\": [], \"targetLangs\": [ \"cs\" ] } ``` Create and assign job in project with workflow step: ``` { \"targetLangs\": [ \"de\" ], \"useProjectFileImportSettings\": \"true\", \"workflowSettings\": [ { \"id\": \"64\", \"due\": \"2007-12-03T10:15:30.00Z\", \"assignments\": [ { \"targetLang\": \"de\", \"providers\": [ { \"id\": \"3\", \"type\": \"VENDOR\" } ] } ], \"notifyProvider\": { \"organizationEmailTemplate\": { \"id\": \"39\" }, \"notificationIntervalInMinutes\": \"10\" } } ] } ``` # noqa: E501

phrasetms_client/configuration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ def to_debug_report(self):
423423
"OS: {env}\n"
424424
"Python Version: {pyversion}\n"
425425
"Version of the API: Latest\n"
426-
"SDK Package Version: 0.3.1".format(env=sys.platform, pyversion=sys.version)
426+
"SDK Package Version: 0.3.2".format(env=sys.platform, pyversion=sys.version)
427427
)
428428

429429
def get_host_settings(self):

phrasetms_client/models/abstract_analyse_settings_dto.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ class Config:
6060
__discriminator_value_class_map = {
6161
'PostAnalyse': 'PostAnalyse',
6262
'PreAnalyse': 'PreAnalyse',
63-
'PreAnalyseTarget, Compare': 'PreAnalyseTargetCompare'
63+
'PreAnalyseTarget': 'PreAnalyseTargetCompare',
64+
'Compare': 'PreAnalyseTargetCompare'
6465
}
6566

6667
@classmethod

phrasetms_client/models/abstract_project_dto.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ class Config:
5656

5757
# discriminator mappings
5858
__discriminator_value_class_map = {
59-
'Admin, Project Manager': 'AdminProjectManager',
60-
'Buyer': 'Buyer',
61-
'Linguist': 'Linguist',
62-
'Vendor': 'Vendor'
59+
'ADMIN': 'AdminProjectManager',
60+
'PROJECT_MANAGER': 'AdminProjectManager',
61+
'BUYER': 'Buyer',
62+
'LINGUIST': 'Linguist',
63+
'VENDOR': 'Vendor'
6364
}
6465

6566
@classmethod

phrasetms_client/models/abstract_project_dto_v2.py

+24-29
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,6 @@ class Config:
5151
allow_population_by_field_name = True
5252
validate_assignment = True
5353

54-
# JSON field name that stores the object type
55-
__discriminator_property_name = 'userRole'
56-
57-
# discriminator mappings
58-
__discriminator_value_class_map = {
59-
'Admin, Project Manager (v2)': 'AdminProjectManagerV2',
60-
'Linguist (v2)': 'LinguistV2'
61-
}
62-
63-
@classmethod
64-
def get_discriminator_value(cls, obj: dict) -> str:
65-
"""Returns the discriminator value (object type) of the data"""
66-
discriminator_value = obj[cls.__discriminator_property_name]
67-
if discriminator_value:
68-
return cls.__discriminator_value_class_map.get(discriminator_value)
69-
else:
70-
return None
71-
7254
def to_str(self) -> str:
7355
"""Returns the string representation of the model using alias"""
7456
return pprint.pformat(self.dict(by_alias=True))
@@ -78,7 +60,7 @@ def to_json(self) -> str:
7860
return json.dumps(self.to_dict())
7961

8062
@classmethod
81-
def from_json(cls, json_str: str) -> Union(AdminProjectManagerV2, LinguistV2): # noqa: F821
63+
def from_json(cls, json_str: str) -> AbstractProjectDtoV2: # noqa: F821
8264
"""Create an instance of AbstractProjectDtoV2 from a JSON string"""
8365
return cls.from_dict(json.loads(json_str))
8466

@@ -115,15 +97,28 @@ def to_dict(self):
11597
return _dict
11698

11799
@classmethod
118-
def from_dict(cls, obj: dict) -> Union(AdminProjectManagerV2, LinguistV2): # noqa: F821
100+
def from_dict(cls, obj: dict) -> AbstractProjectDtoV2: # noqa: F821
119101
"""Create an instance of AbstractProjectDtoV2 from a dict"""
120-
# look up the object type based on discriminator mapping
121-
object_type = cls.get_discriminator_value(obj)
122-
if object_type:
123-
klass = getattr(phrasetms_client.models, object_type)
124-
return klass.from_dict(obj)
125-
else:
126-
raise ValueError("AbstractProjectDtoV2 failed to lookup discriminator value from " +
127-
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
128-
", mapping: " + json.dumps(cls.__discriminator_value_class_map))
102+
if obj is None:
103+
return None
104+
105+
if not isinstance(obj, dict):
106+
return AbstractProjectDtoV2.parse_obj(obj)
107+
108+
_obj = AbstractProjectDtoV2.parse_obj({
109+
"uid": obj.get("uid"),
110+
"internal_id": obj.get("internalId"),
111+
"id": obj.get("id"),
112+
"name": obj.get("name"),
113+
"date_created": obj.get("dateCreated"),
114+
"domain": DomainReference.from_dict(obj.get("domain")) if obj.get("domain") is not None else None,
115+
"sub_domain": SubDomainReference.from_dict(obj.get("subDomain")) if obj.get("subDomain") is not None else None,
116+
"owner": UserReference.from_dict(obj.get("owner")) if obj.get("owner") is not None else None,
117+
"source_lang": obj.get("sourceLang"),
118+
"target_langs": obj.get("targetLangs"),
119+
"references": [ReferenceFileReference.from_dict(_item) for _item in obj.get("references")] if obj.get("references") is not None else None,
120+
"mt_settings_per_language_list": [MTSettingsPerLanguageReference.from_dict(_item) for _item in obj.get("mtSettingsPerLanguageList")] if obj.get("mtSettingsPerLanguageList") is not None else None,
121+
"user_role": obj.get("userRole"),
122+
})
123+
return _obj
129124

phrasetms_client/models/mt_settings_per_language_dto.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MTSettingsPerLanguageDto(BaseModel):
2626
"""
2727
MTSettingsPerLanguageDto
2828
"""
29-
target_lang: StrictStr = Field(..., alias="targetLang", description="mtSettings is set for whole project if targetLang == null")
29+
target_lang: Optional[StrictStr] = Field(..., alias="targetLang", description="mtSettings is set for whole project if targetLang == null")
3030
machine_translate_settings: Optional[MachineTranslateSettingsDto] = Field(None, alias="machineTranslateSettings")
3131
__properties = ["targetLang", "machineTranslateSettings"]
3232

phrasetms_client/models/mt_settings_per_language_reference.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MTSettingsPerLanguageReference(BaseModel):
2626
"""
2727
MTSettingsPerLanguageReference
2828
"""
29-
target_lang: StrictStr = Field(..., alias="targetLang", description="mtSettings is set for whole project if targetLang == null")
29+
target_lang: Optional[StrictStr] = Field(..., alias="targetLang", description="mtSettings is set for whole project if targetLang == null")
3030
machine_translate_settings: Optional[MachineTranslateSettingsReference] = Field(None, alias="machineTranslateSettings")
3131
__properties = ["targetLang", "machineTranslateSettings"]
3232

phrasetms_client/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
class DateTimeEncoder(json.JSONEncoder):
55
def default(self, o):
66
if isinstance(o, datetime):
7-
return o.isoformat()
7+
return o.isoformat().replace("+00:00", "Z")
88

99
return super().default(o)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "phrasetms_client"
3-
version = "0.3.1"
3+
version = "0.3.2"
44
description = "Phrase TMS API"
55
authors = ["Martin Chrástek"]
66
license = "NoLicense"

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# prerequisite: setuptools
2222
# http://pypi.python.org/pypi/setuptools
2323
NAME = "phrasetms-client"
24-
VERSION = "0.3.1"
24+
VERSION = "0.3.2"
2525
PYTHON_REQUIRES = ">=3.7"
2626
REQUIRES = ["urllib3 >= 1.25.3", "python-dateutil", "pydantic >= 1.10.5, < 2", "aenum"]
2727

0 commit comments

Comments
 (0)