Skip to content

Instantly share code, notes, and snippets.

@jaredpalmer jaredpalmer/codegen.sh
Last active Apr 3, 2019

Embed
What would you like to do?
Swagger Codegen TypeScript Axios
#!/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
You can’t perform that action at this time.