start of refactor

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2022-02-27 18:39:04 -08:00
parent e7aaaab78d
commit 2a3cec9aac
10 changed files with 817 additions and 72 deletions

38
generate/generate.py Executable file
View File

@ -0,0 +1,38 @@
#!/usr/bin/env python3
from openapi_parser.parser.loader import OpenApiParser
import os
package_name = 'kittycad'
def main():
cwd = os.getcwd()
path = os.path.join(cwd, 'spec.json')
print("opening spec file: ", path)
parser = OpenApiParser.open(path)
# Ignore the security definitions.
parser.load_metadata()
parser.load_schemas()
parser.load_path_items()
# Generate the types.
generateTypes(cwd, parser)
print([parser])
def generateTypes(cwd: str, parser: OpenApiParser):
# Make sure we have the directory.
path = os.path.join(cwd, 'kittycad', 'models')
os.makedirs(path, exist_ok=True)
# Generate the types.
data = parser.data
schemas = data['components']['schemas']
for key in schemas:
schema = schemas[key]
print(key)
if (__name__ == '__main__'):
exit_code = main()
exit(exit_code)