update the __init__.py

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2022-02-27 20:06:23 -08:00
parent be59e657b9
commit 6c05eabb2c
2 changed files with 21 additions and 4 deletions

View File

@ -26,12 +26,23 @@ def generateTypes(cwd: str, parser: OpenApiParser):
path = os.path.join(cwd, 'kittycad', 'models')
os.makedirs(path, exist_ok=True)
# Open the __init__.py file.
file_name = '__init__.py'
file_path = os.path.join(path, file_name)
f = open(file_path, 'w')
f.write("\"\"\" Contains all the data models used in inputs/outputs \"\"\"\n")
f.write("\n")
# Generate the types.
data = parser.data
schemas = data['components']['schemas']
for key in schemas:
schema = schemas[key]
generateType(path, key, schema)
f.write("from ."+camel_to_snake(key)+" import " + key + "\n")
# Close the file.
f.close()
def generateType(path: str, name: str, schema: dict):
# Generate the type.
@ -250,6 +261,9 @@ def generateType(path: str, name: str, schema: dict):
print(" unsupported type: ", type_name)
return
# Close the file.
f.close()
def hasDateTime(schema: dict) -> bool:
# Generate the type.
if 'type' in schema: