Skip to content

Instantly share code, notes, and snippets.

@who
Last active May 5, 2016 16:03
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 who/3119ce5ec76fa0d2cc6744e5985d4d93 to your computer and use it in GitHub Desktop.
Save who/3119ce5ec76fa0d2cc6744e5985d4d93 to your computer and use it in GitHub Desktop.

This is a quick guide on executing the new javascript generator in swagger 2.1.6

Go to a tmp directory

cd `mktemp -d /tmp/swagger-codegen-XXXXXX`;

Download swagger codegen 2.1.6 jar

wget http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.6/swagger-codegen-cli-2.1.6.jar -O swagger-codegen-cli.jar;

Set a variable for your swagger spec path/url.

SPEC=http://petstore.swagger.io/v2/swagger.json;

Execute swagger codegen, and place the results in the ./output folder

java -jar swagger-codegen-cli.jar generate -l javascript -i $SPEC -o output;

View the results

tree output;

Resulting output

output
├── docs
│   ├── ApiResponse.md
│   ├── Category.md
│   ├── Order.md
│   ├── PetApi.md
│   ├── Pet.md
│   ├── StoreApi.md
│   ├── Tag.md
│   ├── UserApi.md
│   └── User.md
├── git_push.sh
├── package.json
├── README.md
└── src
    ├── api
    │   ├── PetApi.js
    │   ├── StoreApi.js
    │   └── UserApi.js
    ├── ApiClient.js
    ├── index.js
    └── model
        ├── ApiResponse.js
        ├── Category.js
        ├── Order.js
        ├── Pet.js
        ├── Tag.js
        └── User.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment