Skip to content

Commit 082ba48

Browse files
committed
chore: regenerate SDK from latest spec, remove hardcoded test key
- Regenerate factory.py from latest OpenAPI spec (124 endpoints, 10 domains) - Save individual per-product specs to specs/ for reference - Remove hardcoded API key from test_live.py, load from .env (gitignored) - Add .env.example template, skip live tests when key not set - Fix codegen.py bug: oid used before definition - Fix ruff lint violations in generate.py, test_factory.py - Exclude factory.py and codegen.py from ruff (auto-generated code) - Rename examples/fastapi_app.py to examples/app.py
1 parent fbeb527 commit 082ba48

19 files changed

Lines changed: 49738 additions & 7642 deletions

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copy to .env and fill in your values. Never commit .env.
2+
ROXY_TEST_KEY=your-test-api-key
3+
ROXY_BASE_URL=https://roxyapi.com/api/v2

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ openapi-python-client.toml
77
# Generated typed models (excluded from wheel, regenerated locally)
88
src/roxy_sdk/_generated/
99

10+
# Environment / secrets
11+
.env
12+
1013
# Python
1114
__pycache__/
1215
*.py[cod]

codegen.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,14 @@ def main() -> None:
186186
continue
187187
tags = operation.get("tags", ["Other"])
188188
tag = tags[0]
189+
oid = operation.get("operationId", "")
189190
if tag not in TAG_MAP:
190-
print(f"WARNING: Unknown tag '{tag}' for operationId '{oid}'. Add it to TAG_MAP in codegen.py.")
191+
print(
192+
f"WARNING: Unknown tag '{tag}' for "
193+
f"operationId '{oid}'. "
194+
"Add it to TAG_MAP in codegen.py."
195+
)
191196
continue
192-
oid = operation.get("operationId", "")
193197
if not oid:
194198
continue
195199

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
export ROXY_API_KEY="your-api-key" # get one at https://roxyapi.com/pricing
1111
export ROXY_BASE_URL="https://roxyapi.com/api/v2" # optional, this is the default
12-
uvicorn examples.fastapi_app:app --reload --port 8001
12+
cd examples && uvicorn app:app --reload --port 8001
1313
1414
Test with curl:
1515
curl localhost:8001/horoscope/aries
@@ -28,6 +28,7 @@
2828
curl localhost:8001/location/search?q=Mumbai
2929
curl localhost:8001/usage
3030
"""
31+
3132
from __future__ import annotations
3233

3334
import os
@@ -92,8 +93,8 @@ async def daily_horoscope(sign: str, lang: str | None = None):
9293

9394

9495
class ChartRequest(BaseModel):
95-
date: str # YYYY-MM-DD
96-
time: str # HH:MM:SS
96+
date: str # YYYY-MM-DD
97+
time: str # HH:MM:SS
9798
latitude: float
9899
longitude: float
99100
timezone: float = 0.0 # UTC offset in hours (e.g., -5 for EST, 5.5 for IST)

generate.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
66
Run with: python generate.py
77
"""
8+
89
import json
910
import shutil
1011
import subprocess
@@ -58,9 +59,12 @@ def run_openapi_python_client() -> None:
5859
cmd = [
5960
opc_cmd,
6061
"generate",
61-
"--path", str(SPEC_PATH),
62-
"--meta", "none",
63-
"--output-path", str(GENERATED_DIR),
62+
"--path",
63+
str(SPEC_PATH),
64+
"--meta",
65+
"none",
66+
"--output-path",
67+
str(GENERATED_DIR),
6468
]
6569

6670
# Note: openapi-python-client.toml is not used with --meta none
@@ -74,8 +78,10 @@ def run_openapi_python_client() -> None:
7478
sys.exit(result.returncode)
7579

7680
# Count generated files
77-
api_files = list((GENERATED_DIR / "api").rglob("*.py")) if (GENERATED_DIR / "api").exists() else []
78-
model_files = list((GENERATED_DIR / "models").rglob("*.py")) if (GENERATED_DIR / "models").exists() else []
81+
api_dir = GENERATED_DIR / "api"
82+
model_dir = GENERATED_DIR / "models"
83+
api_files = list(api_dir.rglob("*.py")) if api_dir.exists() else []
84+
model_files = list(model_dir.rglob("*.py")) if model_dir.exists() else []
7985
print(f"Generated {len(api_files)} API files, {len(model_files)} model files")
8086

8187

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ build = "hatch build"
6262
[tool.ruff]
6363
line-length = 100
6464
target-version = "py310"
65+
exclude = ["src/roxy_sdk/factory.py", "codegen.py"]
6566

6667
[tool.ruff.lint]
6768
select = ["E", "F", "I", "UP", "B"]

specs/angel-numbers-openapi.json

Lines changed: 1186 additions & 0 deletions
Large diffs are not rendered by default.

specs/astrology-openapi.json

Lines changed: 9489 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)