Last active
May 30, 2016 09:15
-
-
Save YasuhideKato/2cc43d6111836345f39b37d34d4886a6 to your computer and use it in GitHub Desktop.
create APIs SDK with swagger file
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 | |
# FYI: http://swagger.io/ | |
# FYI: https://github.com/swagger-api/swagger-codegen | |
if [ $# != 3 ]; then | |
echo "usage: $0 swagger_url api_sdk_name sdk_lang" 1>&2 | |
exit 0 | |
fi | |
swagger_url=$1 | |
api_sdk_name=$2 | |
sdk_lang=$3 | |
url="https://generator.swagger.io/api/gen/clients" | |
swagger_resource="\"$swagger_url\"" | |
json_payload="{\"swaggerUrl\":$swagger_resource}" | |
sdk_tmp_link=`curl -s -X POST -H "content-type:application/json" -d $json_payload $url/$sdk_lang | jq -r '.link'` | |
echo $sdk_tmp_link | |
wget --no-check-certificate -qO- -O tmp.zip $sdk_tmp_link && mkdir -p $api_sdk_name && unzip tmp.zip -d $api_sdk_name && rm tmp.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
e.g. create petsotre APIs SDK with petstore swagger file
./create_sdk.sh http://petstore.swagger.io/v2/swagger.json petsotre javascript
tree petsotre/
petsotre/
└── javascript-client
├── README.md
├── docs
│ ├── ApiResponse.md
│ ├── Category.md
│ ├── Order.md
│ ├── Pet.md
│ ├── PetApi.md
│ ├── StoreApi.md
│ ├── Tag.md
│ ├── User.md
│ └── UserApi.md
├── git_push.sh
├── package.json
└── src
├── ApiClient.js
├── api
│ ├── PetApi.js
│ ├── StoreApi.js
│ └── UserApi.js
├── index.js
└── model
├── ApiResponse.js
├── Category.js
├── Order.js
├── Pet.js
├── Tag.js
└── User.js
5 directories, 23 files