Created
September 22, 2020 15:11
-
-
Save Hultner/1db54ab67faa5bde542261e5688e52c4 to your computer and use it in GitHub Desktop.
Generate type script interfaces from schema.
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
#!/usr/bin/env sh | |
sed -e 's/export interface components {//' \ | |
-e 's/schemas: {//' -e 's/ }\n}$//' \ | |
-e '$d' models/api.ts \ | |
| sed -e '$d' \ | |
| sed -E 's/[[:space:]]*([A-Z].*)+:[[:space:]]*{/export interface \1 {/' \ | |
| sed -E "s/components\['schemas'\]\['([[:alpha:]_[:digit:]]+)'\]/\1/" > models/api-interface.ts && \ | |
rm models/api.ts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment