Swagger Codgen is command line tool, written in Java, which allows generation of API client libraries, server stubs and documentation given an OpenAPI Specification document.
There are number of ways to install swagger-codegen, including building from source, Homebrew, and running in Docker. Here I’ll describe the Homebrew and running Docker on Vagrant approaches.
Homebrew is the easiest installation option. If you’re writing code for Android, you may need to know that Homebrew will install Java if it’s not already available. I’m not sure if this will affect AndroidStudio etc.
If you want to keep things separate you can use Docker, or you can run Vagrant to fire up a Ubuntu VM, and then run Docker from inside it.
Homebrew
Installation
To install swagger-codegen on your Mac you can use Homebrew:
brew install swagger-codegen
Code Generator
You can then run the code generator:
swagger-codegen generate -i shop.yaml -l python -o shop-python
Vagrant
Installation
We need some source materials to get started, so we clone the Git repository:
git clone https://github.com/swagger-api/swagger-codegen
Then fire up Vagrant, which means your base system will remain untouched:
cd swagger-codegen
vagrant up && vagrant ssh
Setup Docker
cd /vagrant
./run-in-docker.sh mvn package
Code Generator
./run-in-docker.sh generate -i shop.yaml -l python -o shop-python
This will generate Python code in the /vagrant/gen/shop-python directory.