Created
June 17, 2022 00:33
-
-
Save shollingsworth/0fe1f839cef5ebd550a57f9bcac7ceab to your computer and use it in GitHub Desktop.
generate typescript openapi library from openapi json file via docker command
This file contains 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 bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
DIR="$(dirname "$(readlink -f "$0")")" | |
GENERATED_DEST="${DIR}/frontend/src/lib/generatedapi" | |
OPENAPI_FILE="${DIR}/openapi.json" | |
test -d "${GENERATED_DEST}" || rm -rfv "${GENERATED_DEST}" | |
mkdir -p "${GENERATED_DEST}" | |
docker run \ | |
--network=host \ | |
--rm \ | |
-v "$(dirname "${GENERATED_DEST}")":/tmp/output \ | |
-v "${OPENAPI_FILE}:/tmp/openapi.json" \ | |
-u "$(id -u):$(id -g)" \ | |
openapitools/openapi-generator-cli generate \ | |
-i /tmp/openapi.json \ | |
-o "/tmp/output/$(basename "${GENERATED_DEST}")" \ | |
-g typescript-axios \ | |
--additional-properties supportsES6=true \ | |
--additional-properties withInterfaces=true \ | |
--skip-validate-spec |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment