Download web/scripts/gen-api.mjs from EnergyVenom/patch-testing-coworker: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/spaces/EnergyVenom/patch-testing-coworker/resolve/main/web/scripts/gen-api.mjs
- Command line
-
hf download hf://spaces/EnergyVenom/patch-testing-coworker/web/scripts/gen-api.mjs
-
curl -L -o gen-api.mjs https://huggingface.co/spaces/EnergyVenom/patch-testing-coworker/resolve/main/web/scripts/gen-api.mjs
1.12 kB
| // Regenerate the typed API client from FastAPI's OpenAPI: python dumps the schema -> src/api/openapi.json -> | |
| // openapi-typescript -> src/api/schema.d.ts. A backend test (coworker/tests/test_openapi_sync.py) fails on drift. | |
| import { execFileSync } from 'node:child_process'; | |
| import { existsSync, writeFileSync } from 'node:fs'; | |
| import { resolve, dirname } from 'node:path'; | |
| import { fileURLToPath } from 'node:url'; | |
| const here = dirname(fileURLToPath(import.meta.url)); | |
| const root = resolve(here, '..', '..'); | |
| const py = [resolve(root, 'architecture/.venv/Scripts/python.exe'), resolve(root, 'architecture/.venv/bin/python')].find(existsSync) || 'python'; | |
| const json = execFileSync(py, ['-m', 'coworker.api.openapi_dump'], { cwd: root, encoding: 'utf-8', maxBuffer: 64 * 1024 * 1024 }); | |
| const out = resolve(here, '..', 'src', 'api', 'openapi.json'); | |
| writeFileSync(out, json); | |
| execFileSync(process.execPath, [resolve(here, '..', 'node_modules', 'openapi-typescript', 'bin', 'cli.js'), out, '-o', resolve(here, '..', 'src', 'api', 'schema.d.ts')], { stdio: 'inherit' }); | |
| console.log('API types regenerated'); | |