matrix-spec/packages/npm/openapi.sh
2024-03-22 18:21:36 +00:00

24 lines
569 B
Bash
Executable file

#!/usr/bin/env bash
# Script to generate OpenAPI typescript definitions for the Matrix APIs
RELEASE="${npm_package_version%.0}"
SPEC_DIR="v${RELEASE}"
if [ "$RELEASE" == "0.0" ]; then
RELEASE="unstable"
SPEC_DIR="/unstable"
fi
BASE_URL="https://spec.matrix.org/$SPEC_DIR"
for api in application-service client-server push-gateway server-server; do
FILE="$api-api.json"
../../scripts/dump-openapi.py \
--base-url "$BASE_URL" \
--api "$api" \
-r "$RELEASE" \
-o "$FILE"
yarn openapi-typescript "$FILE" --output "$api.d.ts"
rm "$FILE"
done