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