Packer Swaggy C is a Packer builder of Docker image which contains Swagger CodeGen supported languages, Swagger CodeGen CLI jar and Swaggy C.
This is useful when you want to build multiple API clients from an OpenAPI spec without having to install the languages one by one.
Current included languages: Clojure, Dart, Erlang, Go, Java, JavaScript, Perl, PHP, Python, Ruby, Scala, TypeScript. More coming soon!
Pull Swaggy C Docker image from Docker Hub:
docker pull cliffano/swaggy-c
Or alternatively, you can create the Docker image:
git clone https://github.com/cliffano/packer-swaggy-c
cd packer-swaggy-c
make docker
An image with cliffano/swaggy-c
repository and latest
tag should show up:
haku> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
cliffano/swaggy-c latest a9ea23c9807d 7 minutes ago 3.61 GB
ubuntu latest 14f60031763d 7 days ago 120 MB
Execute swaggy-c
to generate the API clients, Swaggy C and Swagger CodeGen are already installed within the container:
docker run \
--workdir /opt/workspace \
-v $(pwd):/opt/workspace \
-t cliffano/swaggy-c \
--rm \
swaggy-c \
--jar /opt/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar \
--api-spec path/to/spec.yml \
javascript-gen
The sample above uses the current working directory as the workspace. The generated API clients will be written to {lang}/generated/
directory.
Path | Description |
---|---|
/usr/local/bin/swaggy-c |
Swaggy C CLI command, available in PATH |
/opt/swaggy-c/bin/info.sh |
Display versions info of all provisioned languages |
/opt/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar |
Swagger CodeGen CLI jar, use this when you want to run the latest jar from the time when the Docker image was created |
As Swagger CodeGen keeps evolving, new languages will be added throughout time. To add a new language support to Packer Swaggy C:
- Create new language provisioning manifest at
modules-extra/swagger_codegen/manifests/langs/<lang>.pp
- If the provisioning manifest requires a new Puppet module, add the dependency to
Puppetfile
- Create the corresponding info script for the new language at
modules-extra/swagger_codegen/files/langs/<lang>-info.sh
, or alternatively if the info script is a templatemodules-extra/swagger_codegen/templates/langs/<lang>-info.sh.epp
- Update
provisioners/swagger-codegen-langs.pp
to include the new language by addinginclude swagger_codegen::langs::<lang>
- Build Swagger Codegen Languages Docker image
make docker-swagger-codegen-langs
- Build Swaggy C Docker image
make docker-swaggy-c
Related Projects:
- swaggy-c - Builder for Swagger CodeGen-generated API clients in multiple languages