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 \
|
--name python-generator \
|
||||||
-v $(CURDIR):/usr/src \
|
-v $(CURDIR):/usr/src \
|
||||||
--workdir /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
|
.PHONY: shell
|
||||||
shell: docker-image ## Pop into a shell in the docker image.
|
shell: docker-image ## Pop into a shell in the docker image.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from openapi_parser.parser.loader import OpenApiParser
|
from openapi_parser.parser.loader import OpenApiParser
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -23,6 +24,29 @@ def main():
|
|||||||
# Generate the paths.
|
# Generate the paths.
|
||||||
generatePaths(cwd, parser)
|
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):
|
def generatePaths(cwd: str, parser: OpenApiParser):
|
||||||
# Make sure we have the directory.
|
# Make sure we have the directory.
|
||||||
|
@ -318,8 +318,12 @@
|
|||||||
"title": "KittyCAD API",
|
"title": "KittyCAD API",
|
||||||
"version": "0.0.2-6f1ca7e",
|
"version": "0.0.2-6f1ca7e",
|
||||||
"x-go": {
|
"x-go": {
|
||||||
"client": "// Create a client with your token and host.\nclient, err := kittycad.NewClient(\"$TOKEN\", \"your apps user agent\")\nif err != nil {\n panic(err)\n}\n\n// - OR -\n\n// Create a new client with your token and host parsed from the environment\n// variables: KITTYCAD_API_TOKEN.\nclient, err := kittycad.NewClientFromEnv(\"your apps user agent\")\nif err != nil {\n panic(err)\n}",
|
"client": "// Create a client with your token.\nclient, err := kittycad.NewClient(\"$TOKEN\", \"your apps user agent\")\nif err != nil {\n panic(err)\n}\n\n// - OR -\n\n// Create a new client with your token parsed from the environment\n// variable: KITTYCAD_API_TOKEN.\nclient, err := kittycad.NewClientFromEnv(\"your apps user agent\")\nif err != nil {\n panic(err)\n}",
|
||||||
"install": "go get github.com/kittycad/kittycad.go"
|
"install": "go get github.com/kittycad/kittycad.go"
|
||||||
|
},
|
||||||
|
"x-python": {
|
||||||
|
"client": "# Create a client with your token.\nfrom kittycad import Client\n\nclient = Client(token=\"$TOKEN\")\n\n# - OR -\n\n# Create a new client with your token parsed from the environment variable:\n# KITTYCAD_API_TOKEN.\nfrom kittycad import ClientFromEnv\n\nclient = ClientFromEnv()",
|
||||||
|
"install": "pip install kittycad"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"openapi": "3.0.0",
|
"openapi": "3.0.0",
|
||||||
|
Reference in New Issue
Block a user