Skip to content

Commit 4b8fc70

Browse files
Refactor union base type string
1 parent 1512225 commit 4b8fc70

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

openapi_python_client/parser/properties/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ def _get_inner_prop_string(self, json: bool = False) -> str:
174174
unique_inner_types = list(dict.fromkeys(inner_types))
175175
return ", ".join(unique_inner_types)
176176

177-
def get_base_type_string(self) -> str:
178-
return f"Union[{self._get_inner_prop_string()}]"
177+
def get_base_type_string(self, json: bool = False) -> str:
178+
return f"Union[{self._get_inner_prop_string(json=json)}]"
179179

180180
def get_type_string(self, no_optional: bool = False, query_parameter: bool = False, json: bool = False) -> str:
181181
"""
@@ -184,7 +184,7 @@ def get_type_string(self, no_optional: bool = False, query_parameter: bool = Fal
184184
This implementation differs slightly from `Property.get_type_string` in order to collapse
185185
nested union types.
186186
"""
187-
type_string = f"Union[{self._get_inner_prop_string(json=json)}]"
187+
type_string = self.get_base_type_string(json=json)
188188
if no_optional:
189189
return type_string
190190
if self.required:

0 commit comments

Comments
 (0)