- #!/usr/bin/env bash
- set -euo pipefail
-
- OPENAPI_URL="${OPENAPI_URL:-http://127.0.0.1:7300/openapi.json}"
- SPEC_FILE="openapi.fetched.json"
- OUTPUT_DIR="src/generated/typescript"
-
- cleanup() {
- rm -f "$SPEC_FILE"
- }
-
- trap cleanup EXIT
-
- curl --fail --silent --show-error \
- --header "Accept: application/json" \
- "$OPENAPI_URL" \
- --output "$SPEC_FILE"
-
- npx openapi-typescript-codegen \
- --input "$SPEC_FILE" \
- --output "$OUTPUT_DIR"
|