Skip to content

Commit 3d16119

Browse files
committed
fix: Correct EmailDomain model field deserialization
Fix OpenAPI spec indentation causing EmailDomainResponse, EmailDomainResponseWithEmbedded and EmailDomain to drop 5-7 fields during deserialization. API responses now include all fields: id, domain, validationStatus, dnsValidationRecords, etc. Fixed incorrect YAML indentation in allOf composition that prevented OpenAPI generator from processing properties beyond BaseEmailDomain. Fixes: OKTA-1133517
1 parent 60ab60a commit 3d16119

11 files changed

Lines changed: 268 additions & 63 deletions

docs/EmailDomain.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55

66
Name | Type | Description | Notes
77
------------ | ------------- | ------------- | -------------
8+
**display_name** | **str** | |
9+
**user_name** | **str** | |
810
**brand_id** | **str** | |
911
**domain** | **str** | |
1012
**validation_subdomain** | **str** | Subdomain for the email sender's custom mail domain. Specify your subdomain when you configure a custom mail domain. | [optional] [default to 'mail']
11-
**display_name** | **str** | |
12-
**user_name** | **str** | |
1313

1414
## Example
1515

docs/EmailDomainResponse.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
Name | Type | Description | Notes
77
------------ | ------------- | ------------- | -------------
8+
**display_name** | **str** | |
9+
**user_name** | **str** | |
810
**dns_validation_records** | [**List[EmailDomainDNSRecord]**](EmailDomainDNSRecord.md) | | [optional]
911
**domain** | **str** | | [optional]
1012
**id** | **str** | | [optional]
1113
**validation_status** | [**EmailDomainStatus**](EmailDomainStatus.md) | | [optional]
1214
**validation_subdomain** | **str** | The subdomain for the email sender's custom mail domain | [optional] [default to 'mail']
13-
**display_name** | **str** | |
14-
**user_name** | **str** | |
1515

1616
## Example
1717

docs/EmailDomainResponseWithEmbedded.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
Name | Type | Description | Notes
77
------------ | ------------- | ------------- | -------------
8-
**embedded** | **object** | | [optional] [readonly]
8+
**display_name** | **str** | |
9+
**user_name** | **str** | |
910
**dns_validation_records** | [**List[EmailDomainDNSRecord]**](EmailDomainDNSRecord.md) | | [optional]
1011
**domain** | **str** | | [optional]
1112
**id** | **str** | | [optional]
1213
**validation_status** | [**EmailDomainStatus**](EmailDomainStatus.md) | | [optional]
1314
**validation_subdomain** | **str** | The subdomain for the email sender's custom mail domain | [optional] [default to 'mail']
14-
**display_name** | **str** | |
15-
**user_name** | **str** | |
15+
**embedded** | [**EmailDomainResponseWithEmbeddedAllOfEmbedded**](EmailDomainResponseWithEmbeddedAllOfEmbedded.md) | | [optional]
1616

1717
## Example
1818

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# EmailDomainResponseWithEmbeddedAllOfEmbedded
2+
3+
4+
## Properties
5+
6+
Name | Type | Description | Notes
7+
------------ | ------------- | ------------- | -------------
8+
**brands** | [**List[Brand]**](Brand.md) | | [optional]
9+
10+
## Example
11+
12+
```python
13+
from okta.models.email_domain_response_with_embedded_all_of_embedded import EmailDomainResponseWithEmbeddedAllOfEmbedded
14+
15+
# TODO update the JSON string below
16+
json = "{}"
17+
# create an instance of EmailDomainResponseWithEmbeddedAllOfEmbedded from a JSON string
18+
email_domain_response_with_embedded_all_of_embedded_instance = EmailDomainResponseWithEmbeddedAllOfEmbedded.from_json(json)
19+
# print the JSON string representation of the object
20+
print(EmailDomainResponseWithEmbeddedAllOfEmbedded.to_json())
21+
22+
# convert the object into a dict
23+
email_domain_response_with_embedded_all_of_embedded_dict = email_domain_response_with_embedded_all_of_embedded_instance.to_dict()
24+
# create an instance of EmailDomainResponseWithEmbeddedAllOfEmbedded from a dict
25+
email_domain_response_with_embedded_all_of_embedded_from_dict = EmailDomainResponseWithEmbeddedAllOfEmbedded.from_dict(email_domain_response_with_embedded_all_of_embedded_dict)
26+
```
27+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
28+
29+

okta/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@
651651
"EmailDomainDNSRecordType": "okta.models.email_domain_dns_record_type",
652652
"EmailDomainResponse": "okta.models.email_domain_response",
653653
"EmailDomainResponseWithEmbedded": "okta.models.email_domain_response_with_embedded",
654+
"EmailDomainResponseWithEmbeddedAllOfEmbedded": "okta.models.email_domain_response_with_embedded_all_of_embedded",
654655
"EmailDomainStatus": "okta.models.email_domain_status",
655656
"EmailPreview": "okta.models.email_preview",
656657
"EmailPreviewLinks": "okta.models.email_preview_links",

okta/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,7 @@
852852
"EmailDomainDNSRecordType": "okta.models.email_domain_dns_record_type",
853853
"EmailDomainResponse": "okta.models.email_domain_response",
854854
"EmailDomainResponseWithEmbedded": "okta.models.email_domain_response_with_embedded",
855+
"EmailDomainResponseWithEmbeddedAllOfEmbedded": "okta.models.email_domain_response_with_embedded_all_of_embedded",
855856
"EmailDomainStatus": "okta.models.email_domain_status",
856857
"EmailPreview": "okta.models.email_preview",
857858
"EmailPreviewLinks": "okta.models.email_preview_links",

okta/models/email_domain.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class EmailDomain(BaseModel):
3737
EmailDomain
3838
""" # noqa: E501
3939

40+
display_name: StrictStr = Field(alias="displayName")
41+
user_name: StrictStr = Field(alias="userName")
4042
brand_id: StrictStr = Field(alias="brandId")
4143
domain: StrictStr
4244
validation_subdomain: Optional[StrictStr] = Field(
@@ -45,9 +47,13 @@ class EmailDomain(BaseModel):
4547
"mail domain.",
4648
alias="validationSubdomain",
4749
)
48-
display_name: StrictStr = Field(alias="displayName")
49-
user_name: StrictStr = Field(alias="userName")
50-
__properties: ClassVar[List[str]] = ["displayName", "userName"]
50+
__properties: ClassVar[List[str]] = [
51+
"displayName",
52+
"userName",
53+
"brandId",
54+
"domain",
55+
"validationSubdomain",
56+
]
5157

5258
model_config = ConfigDict(
5359
populate_by_name=True,
@@ -98,6 +104,16 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
98104
return cls.model_validate(obj)
99105

100106
_obj = cls.model_validate(
101-
{"displayName": obj.get("displayName"), "userName": obj.get("userName")}
107+
{
108+
"displayName": obj.get("displayName"),
109+
"userName": obj.get("userName"),
110+
"brandId": obj.get("brandId"),
111+
"domain": obj.get("domain"),
112+
"validationSubdomain": (
113+
obj.get("validationSubdomain")
114+
if obj.get("validationSubdomain") is not None
115+
else "mail"
116+
),
117+
}
102118
)
103119
return _obj

okta/models/email_domain_response.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class EmailDomainResponse(BaseModel):
4040
EmailDomainResponse
4141
""" # noqa: E501
4242

43+
display_name: StrictStr = Field(alias="displayName")
44+
user_name: StrictStr = Field(alias="userName")
4345
dns_validation_records: Optional[List[EmailDomainDNSRecord]] = Field(
4446
default=None, alias="dnsValidationRecords"
4547
)
@@ -53,9 +55,15 @@ class EmailDomainResponse(BaseModel):
5355
description="The subdomain for the email sender's custom mail domain",
5456
alias="validationSubdomain",
5557
)
56-
display_name: StrictStr = Field(alias="displayName")
57-
user_name: StrictStr = Field(alias="userName")
58-
__properties: ClassVar[List[str]] = ["displayName", "userName"]
58+
__properties: ClassVar[List[str]] = [
59+
"displayName",
60+
"userName",
61+
"dnsValidationRecords",
62+
"domain",
63+
"id",
64+
"validationStatus",
65+
"validationSubdomain",
66+
]
5967

6068
model_config = ConfigDict(
6169
populate_by_name=True,
@@ -94,6 +102,13 @@ def to_dict(self) -> Dict[str, Any]:
94102
exclude=excluded_fields,
95103
exclude_none=True,
96104
)
105+
# override the default output from pydantic by calling `to_dict()` of each item in dns_validation_records (list)
106+
_items = []
107+
if self.dns_validation_records:
108+
for _item in self.dns_validation_records:
109+
if _item:
110+
_items.append(_item.to_dict())
111+
_dict["dnsValidationRecords"] = _items
97112
return _dict
98113

99114
@classmethod
@@ -106,6 +121,25 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
106121
return cls.model_validate(obj)
107122

108123
_obj = cls.model_validate(
109-
{"displayName": obj.get("displayName"), "userName": obj.get("userName")}
124+
{
125+
"displayName": obj.get("displayName"),
126+
"userName": obj.get("userName"),
127+
"dnsValidationRecords": (
128+
[
129+
EmailDomainDNSRecord.from_dict(_item)
130+
for _item in obj["dnsValidationRecords"]
131+
]
132+
if obj.get("dnsValidationRecords") is not None
133+
else None
134+
),
135+
"domain": obj.get("domain"),
136+
"id": obj.get("id"),
137+
"validationStatus": obj.get("validationStatus"),
138+
"validationSubdomain": (
139+
obj.get("validationSubdomain")
140+
if obj.get("validationSubdomain") is not None
141+
else "mail"
142+
),
143+
}
110144
)
111145
return _obj

okta/models/email_domain_response_with_embedded.py

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
from typing_extensions import Self
3333

3434
from okta.models.email_domain_dns_record import EmailDomainDNSRecord
35+
from okta.models.email_domain_response_with_embedded_all_of_embedded import (
36+
EmailDomainResponseWithEmbeddedAllOfEmbedded,
37+
)
3538
from okta.models.email_domain_status import EmailDomainStatus
3639

3740

@@ -40,7 +43,8 @@ class EmailDomainResponseWithEmbedded(BaseModel):
4043
EmailDomainResponseWithEmbedded
4144
""" # noqa: E501
4245

43-
embedded: Optional[object] = Field(default=None, alias="_embedded")
46+
display_name: StrictStr = Field(alias="displayName")
47+
user_name: StrictStr = Field(alias="userName")
4448
dns_validation_records: Optional[List[EmailDomainDNSRecord]] = Field(
4549
default=None, alias="dnsValidationRecords"
4650
)
@@ -54,16 +58,18 @@ class EmailDomainResponseWithEmbedded(BaseModel):
5458
description="The subdomain for the email sender's custom mail domain",
5559
alias="validationSubdomain",
5660
)
57-
display_name: StrictStr = Field(alias="displayName")
58-
user_name: StrictStr = Field(alias="userName")
61+
embedded: Optional[EmailDomainResponseWithEmbeddedAllOfEmbedded] = Field(
62+
default=None, alias="_embedded"
63+
)
5964
__properties: ClassVar[List[str]] = [
65+
"displayName",
66+
"userName",
6067
"dnsValidationRecords",
6168
"domain",
6269
"id",
6370
"validationStatus",
6471
"validationSubdomain",
65-
"displayName",
66-
"userName",
72+
"_embedded",
6773
]
6874

6975
model_config = ConfigDict(
@@ -95,13 +101,8 @@ def to_dict(self) -> Dict[str, Any]:
95101
* `None` is only added to the output dict for nullable fields that
96102
were set at model initialization. Other fields with value `None`
97103
are ignored.
98-
* OpenAPI `readOnly` fields are excluded.
99104
"""
100-
excluded_fields: Set[str] = set(
101-
[
102-
"embedded",
103-
]
104-
)
105+
excluded_fields: Set[str] = set([])
105106

106107
_dict = self.model_dump(
107108
by_alias=True,
@@ -115,6 +116,13 @@ def to_dict(self) -> Dict[str, Any]:
115116
if _item:
116117
_items.append(_item.to_dict())
117118
_dict["dnsValidationRecords"] = _items
119+
# override the default output from pydantic by calling `to_dict()` of embedded
120+
if self.embedded:
121+
if not isinstance(self.embedded, dict):
122+
_dict["_embedded"] = self.embedded.to_dict()
123+
else:
124+
_dict["_embedded"] = self.embedded
125+
118126
return _dict
119127

120128
@classmethod
@@ -128,6 +136,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
128136

129137
_obj = cls.model_validate(
130138
{
139+
"displayName": obj.get("displayName"),
140+
"userName": obj.get("userName"),
131141
"dnsValidationRecords": (
132142
[
133143
EmailDomainDNSRecord.from_dict(_item)
@@ -144,8 +154,13 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
144154
if obj.get("validationSubdomain") is not None
145155
else "mail"
146156
),
147-
"displayName": obj.get("displayName"),
148-
"userName": obj.get("userName"),
157+
"_embedded": (
158+
EmailDomainResponseWithEmbeddedAllOfEmbedded.from_dict(
159+
obj["_embedded"]
160+
)
161+
if obj.get("_embedded") is not None
162+
else None
163+
),
149164
}
150165
)
151166
return _obj

0 commit comments

Comments
 (0)