diff --git a/.dockerignore b/.dockerignore index a0e39ffd165..75ea5de6ca2 100644 --- a/.dockerignore +++ b/.dockerignore @@ -30,7 +30,7 @@ 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-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 diff --git a/.gitignore b/.gitignore index db34c76636c..e42dfdcb021 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,7 @@ 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-java/hello.txt +samples/client/petstore/android/default/hello.txt samples/client/petstore/objc/SwaggerClientTests/Build samples/client/petstore/objc/SwaggerClientTests/Pods samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcworkspace @@ -48,6 +48,7 @@ atlassian-ide-plugin.xml packages/ .pub .packages +.vagrant/ samples/client/petstore/php/SwaggerClient-php/composer.lock samples/client/petstore/php/SwaggerClient-php/vendor/ @@ -55,13 +56,30 @@ samples/client/petstore/php/SwaggerClient-php/vendor/ samples/client/petstore/silex/SwaggerServer/composer.lock samples/client/petstore/silex/SwaggerServer/venodr/ +samples/client/petstore/perl/deep_module_test/ + samples/client/petstore/python/.projectile samples/client/petstore/python/.venv/ +samples/client/petstore/python/dev-requirements.txt.log -*/.settings +samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata +samples/client/petstore/swift/SwaggerClientTests/SwaggerClient.xcodeproj/xcuserdata +samples/client/petstore/swift/SwaggerClientTests/SwaggerClient.xcworkspace/xcuserdata +samples/client/petstore/swift/SwaggerClientTests/Pods/Pods.xcodeproj/xcuserdata +samples/client/petstore/swift/SwaggerClientTests/Pods/Pods.xcodeproj/xcshareddata/xcschemes + +.settings *.mustache~ *.java~ *.pm~ *.xml~ *.t~ + +samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/ +samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/ +**/.gradle/ + +samples/client/petstore/python/dev-requirements.txt.log +samples/client/petstore/python/swagger_client.egg-info/SOURCES.txt +samples/client/petstore/python/.coverage diff --git a/.travis.yml b/.travis.yml index 73dc7fdd26d..46bb326da69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,21 @@ -sudo: false +sudo: required language: java -script: mvn verify -Psamples jdk: - oraclejdk7 + - oraclejdk8 + +services: + - docker + +before_install: + # required when sudo: required for the Ruby petstore tests + - gem install bundler + +install: + +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 + +env: + - DOCKER_IMAGE_NAME=swaggerapi/swagger-generator diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4bef580bb26..35294347b00 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,9 +2,9 @@ ## Before submitting an issue - - Before submitting an issue, search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) and [closed issue](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before. + - Search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) and [closed issue](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before. - The issue should contain details on how to repeat the issue, e.g. - - the Swagger spec for reproducing the issue (:bulb: use [Gist](https://gist.github.com) to share). If the Swagger spec cannot be shared publicly, it will be hard for the community to help + - the OpenAPI Spec for reproducing the issue (:bulb: use [Gist](https://gist.github.com) to share). If the OpenAPI Spec cannot be shared publicly, it will be hard for the community to help - version of Swagger Codegen - language (`-l` in the command line, e.g. java, csharp, php) - You can also make a suggestion or ask a question by opening an "issue" @@ -31,10 +31,12 @@ For a list of variables available in the template, please refer to this [page](h Code change should conform to the programming style guide of the respective langauages: - C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx - Java: https://google.github.io/styleguide/javaguide.html +- JavaScript - https://github.com/airbnb/javascript/tree/master/es5 - ObjC: https://github.com/NYTimes/objective-c-style-guide - PHP: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md - Python: https://www.python.org/dev/peps/pep-0008/ - Ruby: https://github.com/bbatsov/ruby-style-guide +- Swift: https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/Swift_Programming_Language/TheBasics.html - TypeScript: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines @@ -56,7 +58,7 @@ To start the CI tests, you can run `mvn verify -Psamples` (assuming you've all t ### Tips - Smaller changes are easier to review -- [Optional] For bug fixes, provide a Swagger spec to repeat the issue so that the reviewer can use it to confirm the fix +- [Optional] For bug fixes, provide a OpenAPI Spec to repeat the issue so that the reviewer can use it to confirm the fix - Add test case(s) to cover the change - 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) diff --git a/LICENSE b/LICENSE index 542991f9550..ebfd64c4931 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright 2015 SmartBear Software +Copyright 2016 SmartBear Software Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 3f1691144b9..b99ce16bee6 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,15 @@ # Swagger Code Generator -[![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.png)](https://travis-ci.org/swagger-api/swagger-codegen) +[![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.svg)](https://travis-ci.org/swagger-api/swagger-codegen) [![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) +[![PR Stats](http://issuestats.com/github/swagger-api/swagger-codegen/badge/pr)](http://issuestats.com/github/swagger-api/swagger-codegen) [![Issue Stats](http://issuestats.com/github/swagger-api/swagger-codegen/badge/issue)](http://issuestats.com/github/swagger-api/swagger-codegen) :star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22).:star::star::star: ## Overview -This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server. +This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server. -Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more. +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. # Table of contents @@ -22,7 +23,8 @@ Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additi - [Building](#building) - [Docker](#docker) - [Build and run](#build-and-run-using-docker) - - [Build a Node.js server stub](#build-a-nodejs-server-stub) + - [Run docker in Vagrant](#run-docker-in-vagrant) + - [Public Docker image](#public-docker-image) - [Homebrew](#homebrew) - Generators - [To generate a sample client library](#to-generate-a-sample-client-library) @@ -32,47 +34,66 @@ Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additi - [Where is Javascript???](#where-is-javascript) - [Generating a client from local files](#generating-a-client-from-local-files) - [Customizing the generator](#customizing-the-generator) - - [Validating your swagger spec](#validating-your-swagger-spec) + - [Validating your OpenAPI Spec](#validating-your-openapi-spec) - [Generating dynamic html api documentation](#generating-dynamic-html-api-documentation) - [Generating static html api documentation](#generating-static-html-api-documentation) - [To build a server stub](#to-build-a-server-stub) - [Node.js](#nodejs) + - [PHP Slim](#php-slim) - [PHP Silex](#php-silex) - [Python Flask (Connexion)](#python-flask-connexion) - [Ruby Sinatra](#ruby-sinatra) - [Scala Scalatra](#scala-scalatra) - - [Java JAX-RS](#java-jax-rs) + - [Java JAX-RS (Java JAX-RS (Jersey v1.18)](#java-jax-rs-jersey-v118) + - [Java JAX-RS (Apache CXF 3)](#java-jax-rs-apache-cxf-3) - [Java Spring MVC](#java-spring-mvc) + - [Haskell Servant](#haskell-servant) + - [ASP.NET 5 Web API](#aspnet-5-web-api) - [To build the codegen library](#to-build-the-codegen-library) + - [Workflow Integration](#workflow-integration) - [Online Generators](#online-generators) - [Guidelines for Contribution](https://github.com/swagger-api/swagger-codegen/wiki/Guidelines-for-Contribution) + - [Companies/Projects using Swagger Codegen](#companiesprojects-using-swagger-codegen) - [License](#license) ## Compatibility -The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the swagger specification: +The OpenAPI Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the OpenAPI Specification: -Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes +Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes -------------------------- | ------------ | -------------------------- | ----- -2.1.5-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) -2.1.4 (**current stable**) | 2015-10-25 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.4](https://github.com/swagger-api/swagger-codegen/tree/v2.1.4) +2.1.6-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen) +2.1.5 (**current stable**) | 2015-01-06 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.5](https://github.com/swagger-api/swagger-codegen/tree/v2.1.5) 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 -You need the following installed and available in your $PATH: +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): -* [Java 7](http://java.oracle.com) +``` +wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.5/swagger-codegen-cli-2.1.5.jar -o swagger-codegen-cli.jar + +java -jar swagger-codegen-cli.jar help +``` + +On a mac, it's even easier with `brew`: +``` +brew install swagger-codegen +``` + +To build from source, you need the following installed and available in your $PATH: + +* [Java 7 or 8](http://java.oracle.com) * [Apache maven 3.0.3 or greater](http://maven.apache.org/) #### OS X Users -Don't forget to install Java 7. You probably have 1.6 or 1.8. +Don't forget to install Java 7 or 8. You probably have 1.6. Export JAVA_HOME in order to use the supported Java version: ``` -export JAVA_HOME=`/usr/libexec/java_home -v 1.7` +export JAVA_HOME=`/usr/libexec/java_home -v 1.8` export PATH=${JAVA_HOME}/bin:$PATH ``` @@ -88,21 +109,27 @@ mvn package ``` git clone https://github.com/swagger-api/swagger-codegen - cd swagger-codegen - ./run-in-docker.sh mvn package ``` -#### Build a Node.js server stub + +#### Run Docker in Vagrant +Prerequisite: install [Vagrant](https://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads). ``` -./run-in-docker.sh generate \ - -i http://petstore.swagger.io/v2/swagger.json \ - -l nodejs \ - -o samples/server/petstore/nodejs +git clone http://github.com/swagger-api/swagger-codegen.git +cd swagger-codegen +vagrant up +vagrant ssh +cd /vagrant +./run-in-docker.sh mvn package ``` +#### Public Docker image + +https://hub.docker.com/r/swaggerapi/swagger-generator/ + ### Homebrew To install, run `brew install swagger-codegen` @@ -134,18 +161,27 @@ with a number of options. You can get the options with the `help generate` comm ``` NAME - swagger generate - Generate code with chosen lang + swagger-codegen-cli generate - Generate code with chosen lang SYNOPSIS - swagger generate [(-a | --auth )] + swagger-codegen-cli generate + [(-a | --auth )] + [--additional-properties ] + [--api-package ] [--artifact-id ] + [--artifact-version ] [(-c | --config )] - [-D ] + [-D ] [--group-id ] (-i | --input-spec ) + [--import-mappings ] + [--instantiation-types ] + [--invoker-package ] (-l | --lang ) + [--language-specific-primitives ] + [--library ] [--model-package ] [(-o | --output )] - [(-t