Last active
October 10, 2023 17:41
-
-
Save jaredpalmer/fb8155645b3bc5627624b36aa534fa30 to your computer and use it in GitHub Desktop.
Swagger Codegen TypeScript Axios
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
#!/bin/bash | |
# Required: mvn, java, prettier | |
# Assume you have your API running on port 8080 and swagger is available at http://localhost:8080/swagger.json | |
# Assume this script file is in a folder called web that is a sibling to swagger codegen | |
if [[ ! -d ../swagger-codegen/modules/swagger-codegen-cli/target ]]; then | |
cd ../swagger-codegen # path to codegen | |
mvn clean package -DskipTests | |
cd ../web # path to your app | |
fi | |
java -jar ../swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i http://localhost:8080/swagger.json -l typescript-axios -o /tmp/example-api/axios -DmodelPropertyNaming=original | |
rm /tmp/example-api/axios/axios.config.ts # remove this file since it is not codegenned | |
cp -r /tmp/example-api/axios/ src/api/ | |
rm -rf /tmp/example-api | |
yarn prettier --write "src/api/**/*.ts" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment