Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2022-04-06 23:02:47 -07:00
parent be68a24e48
commit 9e96dffb3c
6 changed files with 76 additions and 27 deletions

View File

@ -730,10 +730,23 @@ def generateType(path: str, name: str, schema: dict):
property_name +
": Union[Unset, bool] = False\n")
elif property_type == 'array':
if 'items' in property_schema:
if '$ref' in property_schema['items']:
property_type = property_schema['items']['$ref']
property_type = property_type.replace(
'#/components/schemas/', '')
f.write(
"\t" +
property_name +
": Union[Unset, array] = []\n")
": Union[Unset, List[" +
property_type +
"]] = UNSET\n")
else:
print(" array: ", [property_schema])
print(" array: ", [property_schema['items']])
raise Exception("Unknown array type")
else:
raise Exception("Unknown array type")
else:
raise Exception(" unknown type: ", property_type)
elif '$ref' in property_schema:
@ -821,12 +834,29 @@ def generateType(path: str, name: str, schema: dict):
property_name +
"\n")
elif property_type == 'array':
if 'items' in property_schema:
if '$ref' in property_schema['items']:
property_type = property_schema['items']['$ref']
property_type = property_type.replace(
'#/components/schemas/', '')
f.write(
"\t\t" +
property_name +
": Union[Unset, List[" +
property_type +
"]] = UNSET\n")
f.write(
"\t\tif not isinstance(self." + property_name + ", Unset):\n")
f.write(
"\t\t\t" +
property_name +
" = self." +
property_name +
"\n")
else:
print(" array: ", [property_schema])
print(" array: ", [property_schema['items']])
raise Exception("Unknown array type")
else:
raise Exception(" unknown type: ", property_type)
elif '$ref' in property_schema:
@ -958,13 +988,22 @@ def generateType(path: str, name: str, schema: dict):
"\", UNSET)\n")
f.write("\n")
elif property_type == 'array':
if 'items' in property_schema:
if '$ref' in property_schema['items']:
property_type = property_schema['items']['$ref']
property_type = property_type.replace(
'#/components/schemas/', '')
f.write(
"\t\t" +
property_name +
" = d.pop(\"" +
" = cast(List["+ property_type + "], d.pop(\"" +
property_name +
"\", UNSET)\n")
"\", UNSET))\n")
f.write("\n")
else:
print(" array: ", [property_schema])
print(" array: ", [property_schema['items']])
raise Exception("Unknown array type")
else:
print(" unknown type: ", property_type)
raise Exception(" unknown type: ", property_type)

View File

@ -10,12 +10,14 @@ T = TypeVar("T", bound="ApiCallWithPriceResultsPage")
@attr.s(auto_attribs=True)
class ApiCallWithPriceResultsPage:
""" """
items: Union[Unset, array] = []
items: Union[Unset, List[ApiCallWithPrice]] = UNSET
next_page: Union[Unset, str] = UNSET
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
items: Union[Unset, List[ApiCallWithPrice]] = UNSET
if not isinstance(self.items, Unset):
items = self.items
next_page = self.next_page

View File

@ -10,12 +10,14 @@ T = TypeVar("T", bound="ApiTokenResultsPage")
@attr.s(auto_attribs=True)
class ApiTokenResultsPage:
""" """
items: Union[Unset, array] = []
items: Union[Unset, List[ApiToken]] = UNSET
next_page: Union[Unset, str] = UNSET
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
items: Union[Unset, List[ApiToken]] = UNSET
if not isinstance(self.items, Unset):
items = self.items
next_page = self.next_page

View File

@ -10,12 +10,14 @@ T = TypeVar("T", bound="ExtendedUserResultsPage")
@attr.s(auto_attribs=True)
class ExtendedUserResultsPage:
""" """
items: Union[Unset, array] = []
items: Union[Unset, List[ExtendedUser]] = UNSET
next_page: Union[Unset, str] = UNSET
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
items: Union[Unset, List[ExtendedUser]] = UNSET
if not isinstance(self.items, Unset):
items = self.items
next_page = self.next_page

View File

@ -10,12 +10,14 @@ T = TypeVar("T", bound="FileConversionResultsPage")
@attr.s(auto_attribs=True)
class FileConversionResultsPage:
""" """
items: Union[Unset, array] = []
items: Union[Unset, List[FileConversion]] = UNSET
next_page: Union[Unset, str] = UNSET
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
items: Union[Unset, List[FileConversion]] = UNSET
if not isinstance(self.items, Unset):
items = self.items
next_page = self.next_page

View File

@ -10,12 +10,14 @@ T = TypeVar("T", bound="UserResultsPage")
@attr.s(auto_attribs=True)
class UserResultsPage:
""" """
items: Union[Unset, array] = []
items: Union[Unset, List[User]] = UNSET
next_page: Union[Unset, str] = UNSET
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
def to_dict(self) -> Dict[str, Any]:
items: Union[Unset, List[User]] = UNSET
if not isinstance(self.items, Unset):
items = self.items
next_page = self.next_page