diff --git a/.dockerignore b/.dockerignore index 75ea5de6ca2..664eefdb4ee 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,4 @@ +.git/ *.iml out/ *.ipr @@ -13,35 +14,13 @@ generated-sources/* generated-code/* *.swp *.swo - -/target -/generated-files -/nbactions.xml -*.pyc -__pycache__ -samples/server-generator/scalatra/output -samples/server-generator/node/output/node_modules -samples/server-generator/scalatra/target -samples/server-generator/scalatra/output/.history -samples/client/petstore/qt5cpp/PetStore/moc_* -samples/client/petstore/qt5cpp/PetStore/*.o -samples/client/petstore/objc/PetstoreClient.xcworkspace/xcuserdata -samples/client/petstore/qt5cpp/build-* -samples/client/petstore/qt5cpp/PetStore/PetStore -samples/client/petstore/qt5cpp/PetStore/Makefile -samples/client/petstore/java/hello.txt -samples/client/petstore/android/default/hello.txt -samples/client/petstore/objc/Build -samples/client/petstore/objc/Pods -samples/server/petstore/nodejs/node_modules -target -.idea -.lib -atlassian-ide-plugin.xml +*.bak +project/ +samples/* +target/ +.idea/ +.lib/ .DS_Store -samples/client/petstore/php/SwaggerClient-php/composer.lock -samples/client/petstore/php/SwaggerClient-php/vendor/ - -samples/client/petstore/silex/SwaggerServer/composer.lock -samples/client/petstore/silex/SwaggerServer/venodr/ +# Not needed in a linux container +bin/windows/* diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 89e344b08d2..277a7741fab 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -14,17 +14,17 @@ Also please indicate in the issue title which language/library is concerned. Eg: ##### Swagger declaration file content or url ##### Command line used for generation diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 6f127186321..85641dcbae5 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,6 +1,6 @@ ### PR checklist -- [ ] Read the [contribution guildelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md). +- [ ] Read the [contribution guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md). - [ ] Ran the shell/batch script under `./bin/` to update Petstore sample so that CIs can verify the change. (For instance, only need to run `./bin/{LANG}-petstore.sh` and `./bin/security/{LANG}-petstore.sh` if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates) - [ ] Filed the PR against the correct branch: master for non-breaking changes and `2.3.0` branch for breaking (non-backward compatible) changes. diff --git a/.gitignore b/.gitignore index f49332b6615..370da9c3256 100644 --- a/.gitignore +++ b/.gitignore @@ -143,6 +143,8 @@ samples/client/petstore/typescript-node/**/typings samples/client/petstore/typescript-angular/**/typings samples/client/petstore/typescript-fetch/**/dist/ samples/client/petstore/typescript-fetch/**/typings +samples/client/petstore/typescript-angular2/npm/npm-debug.log +samples/client/petstore/typescript-node/npm/npm-debug.log # aspnetcore samples/server/petstore/aspnetcore/.vs/ diff --git a/.travis.objc_swift_test.yml b/.travis.objc_swift_test.yml index a9ffa3fd23e..8f7cf3b922d 100644 --- a/.travis.objc_swift_test.yml +++ b/.travis.objc_swift_test.yml @@ -31,7 +31,8 @@ before_install: - gem install xcpretty -N --no-ri --no-rdoc - pod --version - pod setup --silent > /dev/null - - brew install xctool + # xctool already pre-installed + #- brew install xctool - git clone https://github.com/wing328/swagger-samples - cd swagger-samples/java/java-jersey-jaxrs && sudo mvn -q jetty:run & @@ -47,6 +48,10 @@ script: - cd $SW/samples/client/petstore/swift/promisekit/SwaggerClientTests && pod install && xcodebuild clean test -workspace "SwaggerClient.xcworkspace" -scheme "SwaggerClient" -sdk iphonesimulator GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty # test default swift client - cd $SW/samples/client/petstore/swift/default/SwaggerClientTests && pod install && xcodebuild clean test -workspace "SwaggerClient.xcworkspace" -scheme "SwaggerClient" -sdk iphonesimulator GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty + # test swift3 client with promisekit + - cd $SW/samples/client/petstore/swift3/promisekit/SwaggerClientTests && pod install && xcodebuild clean test -workspace "SwaggerClient.xcworkspace" -scheme "SwaggerClient" -sdk iphonesimulator GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty + # test default swift3 client + - cd $SW/samples/client/petstore/swift3/default/SwaggerClientTests && pod install && xcodebuild clean test -workspace "SwaggerClient.xcworkspace" -scheme "SwaggerClient" -sdk iphonesimulator GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES | xcpretty env: - DOCKER_IMAGE_NAME=swaggerapi/swagger-generator diff --git a/.travis.yml b/.travis.yml index 1a62cea3161..67273567000 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,24 @@ jdk: cache: directories: - $HOME/.m2 + - $HOME/.ivy2 + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ + - $HOME/samples/client/petstore/php/SwaggerClient-php/vendor + - $HOME/samples/client/petstore/ruby/venodr/bundle + - $HOME/samples/client/petstore/python/.venv/ + - $HOME/samples/client/petstore/typescript-node/npm/node_modules + - $HOME/samples/client/petstore/typescript-node/npm/typings/ + - $HOME/samples/client/petstore/typescript-fetch/tests/default/node_modules + - $HOME/samples/client/petstore/typescript-fetch/tests/default/typings + - $HOME/samples/client/petstore/typescript-fetch/builds/default/node_modules + - $HOME/samples/client/petstore/typescript-fetch/builds/default/typings + - $HOME/samples/client/petstore/typescript-fetch/builds/es6-target/node_modules + - $HOME/samples/client/petstore/typescript-fetch/builds/es6-target/typings + - $HOME/samples/client/petstore/typescript-fetch/builds/with-npm-version/node_modules + - $HOME/samples/client/petstore/typescript-fetch/npm/with-npm-version/typings + - $HOME/samples/client/petstore/typescript-angular/node_modules + - $HOME/samples/client/petstore/typescript-angular/typings services: - docker @@ -24,8 +42,16 @@ before_install: - docker pull swaggerapi/petstore - docker run -d -e SWAGGER_HOST=http://petstore.swagger.io -e SWAGGER_BASE_PATH=/v2 -p 80:8080 swaggerapi/petstore - docker ps -a + # Add bats test framework and cURL for Bash script integration tests + - sudo add-apt-repository ppa:duggan/bats --yes + - sudo apt-get update -qq + - sudo apt-get install -qq bats + - sudo apt-get install -qq curl + # show host table to confirm petstore.swagger.io is mapped to localhost - cat /etc/hosts + # show java version + - java -version install: # Add Godeps dependencies to GOPATH and PATH @@ -34,8 +60,18 @@ install: - export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH" script: - - mvn verify -Psamples - - if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_IMAGE_NAME:latest $DOCKER_IMAGE_NAME:$TRAVIS_TAG; fi && docker push $DOCKER_IMAGE_NAME; fi + # fail fast + - set -e + # fail if templates/generators contain carriage return '\r' + - /bin/bash ./bin/utils/detect_carriage_return.sh + # fail if generators contain tab '\t' + - /bin/bash ./bin/utils/detect_tab_in_java_class.sh + # run integration tests defined in maven pom.xml + - mvn --batch-mode verify -Psamples + # docker: build generator image and push to Docker Hub + - if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/swagger-generator && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME; fi; fi + # docker: build cli image and push to Docker Hub + - if [ $DOCKER_HUB_USERNAME ]; then docker login --email=$DOCKER_HUB_EMAIL --username=$DOCKER_HUB_USERNAME --password=$DOCKER_HUB_PASSWORD && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/swagger-codegen-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME; fi; fi env: - - DOCKER_IMAGE_NAME=swaggerapi/swagger-generator + - DOCKER_GENERATOR_IMAGE_NAME=swaggerapi/swagger-generator DOCKER_CODEGEN_CLI_IMAGE_NAME=swaggerapi/swagger-codegen-cli diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5a169cd7682..cbe94e9063e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,6 +16,12 @@ ## How to contribute +### git + +If you're new to git, you may find the following FAQs useful: + +https://github.com/swagger-api/swagger-codegen/wiki/FAQ#git + ### Code generators All the code generators can be found in [modules/swagger-codegen/src/main/java/io/swagger/codegen/languages](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages) @@ -30,11 +36,15 @@ For a list of variables available in the template, please refer to this [page](h ### Style guide Code change should conform to the programming style guide of the respective languages: - Android: https://source.android.com/source/code-style.html +- Bash: https://github.com/bahamas10/bash-style-guide - C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx - C++: https://google.github.io/styleguide/cppguide.html +- Clojure: https://github.com/bbatsov/clojure-style-guide +- Elixir: https://github.com/christopheradams/elixir_style_guide +- Erlang: https://github.com/inaka/erlang_guidelines - Haskell: https://github.com/tibbe/haskell-style-guide/blob/master/haskell-style.md - Java: https://google.github.io/styleguide/javaguide.html -- JavaScript: https://github.com/airbnb/javascript/tree/master/es5 +- JavaScript: https://github.com/airbnb/javascript/ - Groovy: http://groovy-lang.org/style-guide.html - Go: https://github.com/golang/go/wiki/CodeReviewComments - ObjC: https://github.com/NYTimes/objective-c-style-guide @@ -74,3 +84,5 @@ To start the CI tests, you can run `mvn verify -Psamples` (assuming you've all t - Document the fix in the code to make the code more readable - Make sure test cases passed after the change (one way is to leverage https://travis-ci.org/ to run the CI tests) - File a PR with meaningful title, description and commit messages. A good example is [PR-3306](https://github.com/swagger-api/swagger-codegen/pull/3306) +- Recommended git settings + - `git config --global core.autocrlf input` to tell Git convert CRLF to LF on commit but not the other way around diff --git a/Dockerfile b/Dockerfile index 0a3d093290e..ec291fef4af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,22 @@ -FROM maven:3.3-jdk-7 +FROM jimschubert/8-jdk-alpine-mvn:1.0 -WORKDIR /src -VOLUME /src -VOLUME /root/.m2/repository +ENV GEN_DIR /opt/swagger-codegen -ADD . /opt/swagger-codegen +RUN set -x && \ + apk add --no-cache bash -RUN cd /opt/swagger-codegen && mvn package +RUN mkdir /opt -ENTRYPOINT ["java", "-jar", "/opt/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"] +ADD . ${GEN_DIR} -CMD ["help"] +VOLUME ${MAVEN_HOME}/.m2/repository + +WORKDIR ${GEN_DIR} + +RUN mvn -am -pl "modules/swagger-codegen-cli" package + +COPY docker-entrypoint.sh /usr/local/bin/ + +ENTRYPOINT ["docker-entrypoint.sh"] + +CMD ["build"] diff --git a/README.md b/README.md index a0624137a72..9ae8c0feb48 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Swagger Code Generator -[![Build Status](https://img.shields.io/travis/swagger-api/swagger-codegen.svg?label=Petstore%20Integration%20Test)](https://travis-ci.org/swagger-api/swagger-codegen) +[![Build Status](https://img.shields.io/travis/swagger-api/swagger-codegen/master.svg?label=Petstore%20Integration%20Test)](https://travis-ci.org/swagger-api/swagger-codegen) [![Run Status](https://img.shields.io/shippable/5782588a3be4f4faa56c5bea.svg?label=Mustache%20Template%20Test)](https://app.shippable.com/projects/5782588a3be4f4faa56c5bea) [![Windows Test](https://ci.appveyor.com/api/projects/status/github/swagger-api/swagger-codegen?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/WilliamCheng/swagger-codegen-wh2wu) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project) @@ -12,10 +12,17 @@ :warning: If the OpenAPI/Swagger spec is obtained from an untrusted source, please make sure you've reviewed the spec before using Swagger Codegen to generate the API client, server stub or documentation as [code injection](https://en.wikipedia.org/wiki/Code_injection) may occur :warning: -## Overview -This is the swagger codegen project, which allows generation of API client libraries, server stubs and documentation automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification). +:rocket: ProductHunt: https://producthunt.com/posts/swagger-codegen :rocket: -Check out [Swagger-Spec](https://github.com/OAI/OpenAPI-Specification) for additional information about the Swagger project, including additional libraries with support for other languages and more. +## Overview +This is the swagger codegen project, which allows generation of API client libraries (SDK generation), server stubs and documentation automatically given an [OpenAPI Spec](https://github.com/OAI/OpenAPI-Specification). Currently, the following languages/frameworks are supported: + +- **API clients**: **ActionScript**, **Bash**, **C#** (.net 2.0, 4.0 or later), **C++** (cpprest, Qt5, Tizen), **Clojure**, **Dart**, **Elixir**, **Go**, **Groovy**, **Haskell**, **Java** (Jersey1.x, Jersey2.x, OkHttp, Retrofit1.x, Retrofit2.x, Feign), **Node.js** (ES5, ES6, AngularJS with Google Closure Compiler annotations) **Objective-C**, **Perl**, **PHP**, **Python**, **Ruby**, **Scala**, **Swift** (2.x, 3.x), **Typescript** (Angular1.x, Angular2.x, Fetch, jQuery, Node) +- **Server stubs**: **C#** (ASP.NET Core, NancyFx), **Erlang**, **Go**, **Haskell**, **Java** (MSF4J, Spring, Undertow, JAX-RS: CDI, CXF, Inflector, RestEasy), **PHP** (Lumen, Slim, Silex, [Zend Expressive](https://github.com/zendframework/zend-expressive)), **Python** (Flask), **NodeJS**, **Ruby** (Sinatra, Rails5), **Scala** ([Finch](https://github.com/finagle/finch), Scalatra) +- **API documentation generators**: **HTML**, **Confluence Wiki** +- **Others**: **JMeter** + +Check out [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) for additional information about the OpenAPI project. # Table of contents @@ -61,19 +68,20 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20 Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes -------------------------- | ------------ | -------------------------- | ----- -2.3.0 (upcoming minor release) | TBD | 1.0, 1.1, 1.2, 2.0 | Minor release with breaking changes -2.2.2 (upcoming patch release) | TBD | 1.0, 1.1, 1.2, 2.0 | Patch release (without breaking changes) -2.2.1 (**current stable**) | 2016-08-07 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.1](https://github.com/swagger-api/swagger-codegen/tree/v2.2.1) -2.1.6 | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6) +2.3.0 (upcoming minor release) | Apr/May 2017 | 1.0, 1.1, 1.2, 2.0 | Minor release with breaking changes +2.2.3 (upcoming patch release) | TBD | 1.0, 1.1, 1.2, 2.0 | Patch release without breaking changes +[2.2.2](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.2.2) (**current stable**) | 2017-03-01 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.2](https://github.com/swagger-api/swagger-codegen/tree/v2.2.2) +[2.2.1](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.2.1) | 2016-08-07 | 1.0, 1.1, 1.2, 2.0 | [tag v2.2.1](https://github.com/swagger-api/swagger-codegen/tree/v2.2.1) +[2.1.6](https://github.com/swagger-api/swagger-codegen/releases/tag/v2.1.6) | 2016-04-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.6](https://github.com/swagger-api/swagger-codegen/tree/v2.1.6) 2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17) 1.0.4 | 2012-04-12 | 1.0, 1.1 | [tag v1.0.4](https://github.com/swagger-api/swagger-codegen/tree/swagger-codegen_2.9.1-1.1) ### Prerequisites -If you're looking for the latest stable version, you can grab it directly from maven central (you'll need java 7 runtime at a minimum): +If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 7 runtime at a minimum): ``` -wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.1/swagger-codegen-cli-2.2.1.jar -O swagger-codegen-cli.jar +wget http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.2/swagger-codegen-cli-2.2.2.jar -O swagger-codegen-cli.jar java -jar swagger-codegen-cli.jar help ``` @@ -105,16 +113,41 @@ After cloning the project, you can build it from source with this command: mvn clean package ``` +### Homebrew + +To install, run `brew install swagger-codegen` + +Here is an example usage: +``` +swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l ruby -o /tmp/test/ +``` + ### Docker -#### Build and run using docker + +#### Development in docker + +You can use `run-in-docker.sh` to do all development. This script maps your local repository to `/gen` +in the docker container. It also maps `~/.m2/repository` to the appropriate container location. + +To execute `mvn package`: ``` git clone https://github.com/swagger-api/swagger-codegen cd swagger-codegen ./run-in-docker.sh mvn package - ``` +``` +Build artifacts are now accessible in your working directory. +Once built, `run-in-docker.sh` will act as an executable for swagger-codegen-cli. To generate code, you'll need to output to a directory under `/gen` (e.g. `/gen/out`). For example: + +``` +./run-in-docker.sh help # Executes 'help' command for swagger-codegen-cli +./run-in-docker.sh langs # Executes 'langs' command for swagger-codegen-cli +./run-in-docker.sh /gen/bin/go-petstore.sh # Builds the Go client +./run-in-docker.sh generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml \ + -l go -o /gen/out/go-petstore -DpackageName=petstore # generates go client, outputs locally to ./out/go-petstore +``` #### Run Docker in Vagrant Prerequisite: install [Vagrant](https://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads). @@ -127,18 +160,54 @@ cd /vagrant ./run-in-docker.sh mvn package ``` -#### Public Docker image +#### Public Pre-built Docker images - - https://hub.docker.com/r/swaggerapi/swagger-generator/ (official) - - https://hub.docker.com/r/jimschubert/swagger-codegen-cli/ (unofficial) + - https://hub.docker.com/r/swaggerapi/swagger-generator/ (official web service) + - https://hub.docker.com/r/swaggerapi/swagger-codegen-cli/ (official CLI) -### Homebrew -To install, run `brew install swagger-codegen` -Here is an example usage: +##### Swagger Generator Docker Image + +The Swagger Generator image can act as a self-hosted web application and API for generating code. This container can be incorporated into a CI pipeline, and requires at least two HTTP requests and some docker orchestration to access generated code. + +Example usage (note this assumes `jq` is installed for command line processing of JSON): + ``` -swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -l ruby -o /tmp/test/ +# Start container and save the container id +CID=$(docker run -d swaggerapi/swagger-generator) +# allow for startup +sleep 5 +# Get the IP of the running container +GEN_IP=$(docker inspect --format '{{.NetworkSettings.IPAddress}}' $CID) +# Execute an HTTP request and store the download link +RESULT=$(curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ + "swaggerUrl": "http://petstore.swagger.io/v2/swagger.json" +}' 'http://localhost:8188/api/gen/clients/javascript' | jq '.link' | tr -d '"') +# Download the generated zip and redirect to a file +curl $RESULT > result.zip +# Shutdown the swagger generator image +docker stop $CID && docker rm $CID ``` + +In the example above, `result.zip` will contain the generated client. + +##### Swagger Codegen CLI Docker Image + +The Swagger Codegen image acts as a standalone executable. It can be used as an alternative to installing via homebrew, or for developers who are unable to install Java or upgrade the installed version. + +To generate code with this image, you'll need to mount a local location as a volume. + +Example: + +``` +docker run --rm -v ${PWD}:/local swaggerapi/swagger-codegen-cli generate \ + -i http://petstore.swagger.io/v2/swagger.json \ + -l go \ + -o /local/out/go +``` + +The generated code will be located under `./out/go` in the current directory. + ## Getting Started To generate a PHP client for http://petstore.swagger.io/v2/swagger.json, please run the following @@ -153,7 +222,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ ``` (if you're on Windows, replace the last command with `java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client`) -You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.1/swagger-codegen-cli-2.2.1.jar ) +You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.2.2/swagger-codegen-cli-2.2.2.jar) To get a list of **general** options available, please run `java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help generate` @@ -179,7 +248,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \ -o samples/client/petstore/java ``` -with a number of options. You can get the options with the `help generate` command: +with a number of options. You can get the options with the `help generate` command (below only shows partal results): ``` NAME @@ -210,79 +279,8 @@ OPTIONS adds authorization headers when fetching the swagger definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values - - --additional-properties - sets additional properties that can be referenced by the mustache - templates in the format of name=value,name=value - - --api-package - package for generated api classes - - --artifact-id - artifactId in generated pom.xml - - --artifact-version - artifact version in generated pom.xml - - -c , --config - Path to json configuration file. File content should be in a json - format {"optionKey":"optionValue", "optionKey1":"optionValue1"...} - Supported options can be different for each language. Run - config-help -l {lang} command for language specific config options. - - -D - sets specified system properties in the format of - name=value,name=value - - --group-id - groupId in generated pom.xml - - -i , --input-spec - location of the swagger spec, as URL or file (required) - - - --import-mappings - specifies mappings between a given class and the import that should - be used for that class in the format of type=import,type=import - - --instantiation-types - sets instantiation type mappings in the format of - type=instantiatedType,type=instantiatedType.For example (in Java): - array=ArrayList,map=HashMap. In other words array types will get - instantiated as ArrayList in generated code. - - --invoker-package - root package for generated code - - -l , --lang - client language to generate (maybe class name in classpath, - required) - - --language-specific-primitives - specifies additional language specific primitive types in the format - of type1,type2,type3,type3. For example: - String,boolean,Boolean,Double - - --library - library template (sub-template) - - --model-package - package for generated models - - -o , --output - where to write the generated files (current dir by default) - - -s, --skip-overwrite - specifies if the existing files should be overwritten during the - generation. - - -t