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

View File

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

View File

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

View File

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

View File

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

View File

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