infiniteradio / scripts /generate.sh
JonCard's picture
Claude Opus 5.5
Add Infinite Radio server for Hugging Face Spaces
ab98ae3
Raw History Blame Contribute Delete
753 Bytes
#!/usr/bin/env bash
# Regenerates the FastAPI routes and models in generated/ from infiniteradio.yml.
# Run after every change to the API definition; never edit generated/ by hand.
# Optional argument: output directory (default: generated).
set -euo pipefail
cd "$(dirname "$0")/.."
out="${1:-generated}"
# Import sorting depends on the output location, so always generate in a temp
# directory to get the same result wherever the output goes.
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
fastapi-codegen \
--input infiniteradio.yml \
--output "$tmp/generated" \
--template-dir codegen/templates \
--output-model-type pydantic_v2.BaseModel \
--disable-timestamp
touch "$tmp/generated/__init__.py"
rm -rf "$out"
cp -R "$tmp/generated" "$out"