Last active
November 30, 2021 21:47
-
-
Save Goldziher/364ff383ae96a532cb01a4fbf3406d33 to your computer and use it in GitHub Desktop.
Script to generate api specs from a given api using DTSGenerator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SPECS_DOWNLOAD_URL="https://url-of-api.com/specs" | |
FILE="$PWD/src/my-api-specs.ts" | |
if [[ -f "$FILE" ]]; then | |
rm "$FILE" | |
fi | |
# use dtsgen to generate the target typescript file | |
dtsgen --url $SPECS_DOWNLOAD_URL >> "$FILE" | |
# rewrie namespaces to be exported, allowing for named imports | |
sed -i '' 's/namespace/export namespace/g' "$FILE" | |
sed -i '' 's/declare export/export declare/g' "$FILE" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment