mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
feat(hanzoai): regenerate client from unified OpenAPI spec (retire Stainless) (#45)
Replace the Stainless-generated `hanzoai` client (188 legacy LLM-gateway endpoints) with an openapi-generator `python` (urllib3 + pydantic v2) client built from hanzoai/openapi `hanzo.yaml` — the full unified api.hanzo.ai/v1 surface (493 API groups, 1710 models, all /v1 products). - scripts/generate.sh: the one-way generator; emits only pkg/hanzoai (other pkg/hanzo-* packages untouched). - pyproject: deps -> urllib3 / python-dateutil / pydantic>=2 / typing-extensions; version 2.2.3 -> 3.0.0 (breaking surface change). - tests/: Stainless client tests replaced with a surface smoke test. - .github/workflows/generate.yml: regenerate on openapi spec-update. - Base URL https://api.hanzo.ai, Bearer hk- / JWT auth. Verified: wheel hanzoai-3.0.0 builds, installs into a clean venv, and `import hanzoai` + product API construction succeed. Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
committed by
GitHub
co-authored by
Hanzo Dev
parent
565426aa84
commit
bcd56c6910
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerate the Hanzo Python client (`hanzoai`) from the unified OpenAPI spec.
|
||||
#
|
||||
# The ONE way: hanzoai/openapi `hanzo.yaml` is the single source of truth. The
|
||||
# `hanzoai` package under pkg/ is generated from it with openapi-generator — no
|
||||
# Stainless. Other pkg/hanzo-* packages are hand-written and untouched here.
|
||||
#
|
||||
# ./scripts/generate.sh # pulls spec from hanzoai/openapi@main
|
||||
# SPEC=/path/to/hanzo.yaml ./scripts/generate.sh # local spec override
|
||||
#
|
||||
# Requires: java 17+, curl.
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
GENERATOR_VERSION="${GENERATOR_VERSION:-7.14.0}"
|
||||
SPEC_URL="${SPEC_URL:-https://raw.githubusercontent.com/hanzoai/openapi/main/hanzo.yaml}"
|
||||
SPEC="${SPEC:-}"
|
||||
JAR="${JAR:-/tmp/openapi-generator-cli-${GENERATOR_VERSION}.jar}"
|
||||
|
||||
if [ -z "$SPEC" ]; then
|
||||
SPEC="$(mktemp)"; curl -fsSL "$SPEC_URL" -o "$SPEC"
|
||||
fi
|
||||
if [ ! -f "$JAR" ]; then
|
||||
curl -fsSL -o "$JAR" \
|
||||
"https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/${GENERATOR_VERSION}/openapi-generator-cli-${GENERATOR_VERSION}.jar"
|
||||
fi
|
||||
|
||||
OUT="$(mktemp -d)"
|
||||
java -jar "$JAR" generate \
|
||||
-i "$SPEC" -g python \
|
||||
--additional-properties=packageName=hanzoai,projectName=hanzoai,library=urllib3 \
|
||||
--global-property=apiTests=false,modelTests=false,apiDocs=false,modelDocs=false \
|
||||
--git-user-id=hanzoai --git-repo-id=python-sdk \
|
||||
-o "$OUT"
|
||||
|
||||
# Only the package itself lives in this monorepo (pkg/hanzoai). The generated
|
||||
# pyproject/setup/README/etc. are discarded — the repo root owns build config.
|
||||
rm -rf pkg/hanzoai
|
||||
cp -r "$OUT/hanzoai" pkg/hanzoai
|
||||
echo "generated $(find pkg/hanzoai -name '*.py' | wc -l) python files into pkg/hanzoai"
|
||||
Reference in New Issue
Block a user