write the data back out.
Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
2
Makefile
2
Makefile
@ -15,7 +15,7 @@ generate: docker-image ## Generate the api client.
|
||||
--name python-generator \
|
||||
-v $(CURDIR):/usr/src \
|
||||
--workdir /usr/src \
|
||||
$(DOCKER_IMAGE_NAME) sh -c 'poetry run python generate/generate.py && poetry run autopep8 --in-place --aggressive --aggressive kittycad/models/*.py && poetry run autopep8 --in-place --aggressive --aggressive kittycad/api/*.py'
|
||||
$(DOCKER_IMAGE_NAME) sh -c 'poetry run python generate/generate.py && poetry run autopep8 --in-place --aggressive --aggressive kittycad/models/*.py && poetry run autopep8 --in-place --aggressive --aggressive kittycad/api/*.py && poetry run autopep8 --in-place --aggressive --aggressive kittycad/*.py && poetry run autopep8 --in-place --aggressive --aggressive generate/*.py'
|
||||
|
||||
.PHONY: shell
|
||||
shell: docker-image ## Pop into a shell in the docker image.
|
||||
|
@ -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.
|
||||
|
Reference in New Issue
Block a user