Skip to content

Instantly share code, notes, and snippets.

@Hultner
Created September 22, 2020 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hultner/1db54ab67faa5bde542261e5688e52c4 to your computer and use it in GitHub Desktop.
Save Hultner/1db54ab67faa5bde542261e5688e52c4 to your computer and use it in GitHub Desktop.
Generate type script interfaces from schema.
#!/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