@ -85,14 +85,12 @@ def generateType(path: str, name: str, schema: dict):
|
|||||||
elif property_type == 'boolean':
|
elif property_type == 'boolean':
|
||||||
f.write("\t"+property_name+": Union[Unset, bool] = False\n")
|
f.write("\t"+property_name+": Union[Unset, bool] = False\n")
|
||||||
else:
|
else:
|
||||||
print(" unknown type: ", property_type)
|
raise (" unknown type: ", property_type)
|
||||||
raise
|
|
||||||
elif '$ref' in property_schema:
|
elif '$ref' in property_schema:
|
||||||
ref = property_schema['$ref'].replace('#/components/schemas/', '')
|
ref = property_schema['$ref'].replace('#/components/schemas/', '')
|
||||||
f.write("\t"+property_name+": Union[Unset, "+ref+"] = UNSET\n")
|
f.write("\t"+property_name+": Union[Unset, "+ref+"] = UNSET\n")
|
||||||
else:
|
else:
|
||||||
print(" unknown schema: ", property_schema)
|
raise (" unknown schema: ", property_schema)
|
||||||
raise
|
|
||||||
|
|
||||||
# Finish writing the class.
|
# Finish writing the class.
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
@ -124,16 +122,14 @@ def generateType(path: str, name: str, schema: dict):
|
|||||||
elif property_type == 'boolean':
|
elif property_type == 'boolean':
|
||||||
f.write("\t"+property_name+" = self."+property_name+"\n")
|
f.write("\t"+property_name+" = self."+property_name+"\n")
|
||||||
else:
|
else:
|
||||||
print(" unknown type: ", property_type)
|
raise (" unknown type: ", property_type)
|
||||||
raise
|
|
||||||
elif '$ref' in property_schema:
|
elif '$ref' in property_schema:
|
||||||
ref = property_schema['$ref'].replace('#/components/schemas/', '')
|
ref = property_schema['$ref'].replace('#/components/schemas/', '')
|
||||||
f.write("\t\t"+property_name+": Union[Unset, str] = UNSET\n")
|
f.write("\t\t"+property_name+": Union[Unset, str] = UNSET\n")
|
||||||
f.write("\t\tif not isinstance(self."+property_name+", Unset):\n")
|
f.write("\t\tif not isinstance(self."+property_name+", Unset):\n")
|
||||||
f.write("\t\t\t"+property_name+" = self."+property_name+".value\n")
|
f.write("\t\t\t"+property_name+" = self."+property_name+".value\n")
|
||||||
else:
|
else:
|
||||||
print(" unknown schema: ", property_schema)
|
raise (" unknown schema: ", property_schema)
|
||||||
raise
|
|
||||||
|
|
||||||
# Finish writing the to_dict method.
|
# Finish writing the to_dict method.
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
Reference in New Issue
Block a user