write the data back out.

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2022-02-27 21:59:28 -08:00
parent 653d2b21ee
commit 89a450f697
3 changed files with 687 additions and 659 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
from openapi_parser.parser.loader import OpenApiParser
import json
import os
import re
@ -23,6 +24,29 @@ def main():
# Generate the paths.
generatePaths(cwd, parser)
# Add the client information to the generation.
data = parser.data
data['info']['x-python'] = {
'client': """# Create a client with your token.
from kittycad import Client
client = Client(token="$TOKEN")
# - OR -
# Create a new client with your token parsed from the environment variable:
# KITTYCAD_API_TOKEN.
from kittycad import ClientFromEnv
client = ClientFromEnv()""",
'install': 'pip install kittycad',
}
# Rewrite the spec back out.
f = open(path, 'w')
f.write(json.dumps(data, indent=4))
f.close()
def generatePaths(cwd: str, parser: OpenApiParser):
# Make sure we have the directory.