6
.github/workflows/update-spec-for-docs.yml
vendored
6
.github/workflows/update-spec-for-docs.yml
vendored
@ -40,8 +40,8 @@ jobs:
|
||||
- name: move spec to docs
|
||||
shell: bash
|
||||
run: |
|
||||
rm docs/spec.json || true
|
||||
cp spec.json docs/spec.json
|
||||
rm docs/kittycad.py.patch.json || true
|
||||
cp kittycad.py.patch.json docs/kittycad.py.patch.json
|
||||
- name: commit the changes in the docs repo
|
||||
shell: bash
|
||||
run: |
|
||||
@ -53,7 +53,7 @@ jobs:
|
||||
git commit -am "YOYO NEW SPEC DOCS ${VERSION}!" || exit 0
|
||||
git fetch origin
|
||||
git rebase origin/main || exit 0
|
||||
export NEW_BRANCH="update-spec-${VERSION}"
|
||||
export NEW_BRANCH="update-spec-python"
|
||||
git checkout -b "$NEW_BRANCH"
|
||||
git push -f origin "$NEW_BRANCH"
|
||||
gh pr create --title "Update lang spec docs for ${VERSION}" \
|
||||
|
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
from prance import BaseParser
|
||||
import jsonpatch
|
||||
|
||||
import json
|
||||
import os
|
||||
@ -10,9 +11,9 @@ package_name = 'kittycad'
|
||||
|
||||
def main():
|
||||
cwd = os.getcwd()
|
||||
path = os.path.join(cwd, 'spec.json')
|
||||
print("opening spec file: ", path)
|
||||
parser = BaseParser(path)
|
||||
spec_path = os.path.join(cwd, 'spec.json')
|
||||
print("opening spec file: ", spec_path)
|
||||
parser = BaseParser(spec_path)
|
||||
|
||||
# Generate the types.
|
||||
generateTypes(cwd, parser.specification)
|
||||
@ -30,16 +31,23 @@ client = Client(token="$TOKEN")
|
||||
# - OR -
|
||||
|
||||
# Create a new client with your token parsed from the environment variable:
|
||||
# KITTYCAD_API_TOKEN.
|
||||
# `KITTYCAD_API_TOKEN`.
|
||||
from kittycad import ClientFromEnv
|
||||
|
||||
client = ClientFromEnv()""",
|
||||
'install': 'pip install kittycad',
|
||||
}
|
||||
|
||||
# Read the original spec file as a dict.
|
||||
spec = open(spec_path, 'r')
|
||||
original = json.load(spec)
|
||||
# Create the json patch document.
|
||||
patch = jsonpatch.make_patch(original, data)
|
||||
|
||||
# Rewrite the spec back out.
|
||||
f = open(path, 'w')
|
||||
f.write(json.dumps(data, indent=4))
|
||||
patch_file = os.path.join(cwd, 'kittycad.py.patch.json')
|
||||
f = open(patch_file, 'w')
|
||||
f.write(patch.to_string())
|
||||
f.close()
|
||||
|
||||
|
||||
|
1
kittycad.py.patch.json
Normal file
1
kittycad.py.patch.json
Normal file
@ -0,0 +1 @@
|
||||
[{"op": "replace", "path": "/info/x-python/client", "value": "# 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()"}]
|
@ -33,6 +33,7 @@ openapi-parser = "^0.2.6"
|
||||
autopep8 = "^1.6.0"
|
||||
prance = "^0.21.8"
|
||||
openapi-spec-validator = "^0.4.0"
|
||||
jsonpatch = "^1.32"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=1.0"]
|
||||
|
Reference in New Issue
Block a user