Skip to content

Commit

Permalink
Merge remote-tracking branch 'swagger-api/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Edubits committed Oct 19, 2015
2 parents 39ac64d + 4ea797d commit 09f6099
Show file tree
Hide file tree
Showing 471 changed files with 22,169 additions and 11,227 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ target
.lib
atlassian-ide-plugin.xml
.DS_Store
packages/
.pub
.packages

samples/client/petstore/php/SwaggerClient-php/composer.lock
samples/client/petstore/php/SwaggerClient-php/vendor/
Expand All @@ -50,3 +53,5 @@ samples/client/petstore/silex/SwaggerServer/venodr/

samples/client/petstore/python/.projectile
samples/client/petstore/python/.venv/

*/.settings
57 changes: 50 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,45 @@
# Swagger Code Generator

[![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.png)](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)

## Overview
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.

# Table of contents

- [Swagger Code Generator](#swagger-code-generator)
- [Overview](#overview)
- [Table of Contents](#table-of-contents)
- Installation
- [Build and run using docker](#build-and-run-using-docker)
- [Build a nodejs server stub](#build-a-nodejs-server-stub)
- [Compatibility](#compatibility)
- [Prerequisites](#prerequisites)
- [OS X Users](#os-x-users)
- [Building](#building)
- Generators
- [To generate a sample client library](#to-generate-a-sample-client-library)
- [Generating libraries from your server](#generating-libraries-from-your-server)
- [Modifying the client library format](#modifying-the-client-library-format)
- [Making your own codegen modules](#making-your-own-codegen-modules)
- [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)
- [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)
- [rails-grape](#rails-grape)
- [scala scalatra](#scala-scalatra)
- [java jax-rs](#java-jax-rs)
- [java spring-mvc](#java-spring-mvc)
- [To build the codegen library](#to-build-the-codegen-library)
- [License](#license)

## Build and run using docker

```
Expand All @@ -17,7 +50,7 @@ cd swagger-codegen
./run-in-docker.sh mvn package
```

Build a nodejs server stub:
## Build a nodejs server stub

```
./run-in-docker.sh generate \
Expand All @@ -31,7 +64,7 @@ The Swagger Specification has undergone 3 revisions since initial creation in 20

Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
-------------------------- | ------------ | -------------------------- | -----
2.1.4-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
2.1.4-SNAPSHOT | | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
2.1.3 (**current stable**) | 2015-08-24 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.3](https://github.com/swagger-api/swagger-codegen/tree/v2.1.3)
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)
Expand Down Expand Up @@ -169,7 +202,7 @@ static code generation.
There is a third-party component called [swagger-js-codegen](https://github.com/wcandillon/swagger-js-codegen) that can generate angularjs or nodejs source code from a swagger specification.


#### Generating a client from flat files (i.e. no remote server calls)
#### Generating a client from local files
If you don't want to call your server, you can save the swagger spec files into a directory and pass an argument
to the code generator like this:

Expand All @@ -190,8 +223,8 @@ AkkaScalaClientCodegen.java
AndroidClientCodegen.java
AsyncScalaClientCodegen.java
CSharpClientCodegen.java
CodeGenStatus.java
CsharpDotNet2ClientCodegen.java
DartClientCodegen.java
FlashClientCodegen.java
JavaClientCodegen.java
JavaInflectorServerCodegen.java
Expand All @@ -200,10 +233,8 @@ NodeJSServerCodegen.java
ObjcClientCodegen.java
PerlClientCodegen.java
PhpClientCodegen.java
Python3ClientCodegen.java
PythonClientCodegen.java
Qt5CPPGenerator.java
RetrofitClientCodegen.java
RubyClientCodegen.java
ScalaClientCodegen.java
ScalatraServerCodegen.java
Expand Down Expand Up @@ -245,6 +276,9 @@ CONFIG OPTIONS
apiPackage
package for generated api classes
sortParamsByRequiredFlag
Sort method arguments to place required parameters before optional parameters. Default: true
invokerPackage
root package for generated code
Expand All @@ -260,10 +294,18 @@ CONFIG OPTIONS
sourceFolder
source folder for generated code
localVariablePrefix
prefix for generated code members and local variables
serializableModel
boolean - toggle "implements Serializable" for generated models
library
library template (sub-template) to use:
<default> - HTTP client: Jersey client 1.18. JSON processing: Jackson 2.4.2
jersey2 - HTTP client: Jersey client 2.6
okhttp-gson - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1
retrofit - HTTP client: OkHttp 2.4.0. JSON processing: Gson 2.3.1 (Retrofit 1.9.0)
```

Your config file for java can look like
Expand Down Expand Up @@ -335,6 +377,7 @@ open index.html
You can also use the codegen to generate a server for a couple different frameworks. Take a look here:

### node.js

```
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
-i http://petstore.swagger.io/v2/swagger.json \
Expand All @@ -343,8 +386,8 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
```

### rails-grape
#### Not yet migrated to this branch

*Not yet migrated to this branch*

### scala scalatra
```
Expand Down
4 changes: 2 additions & 2 deletions bin/all-petstore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ cd $APP_DIR
./bin/html-petstore.sh
./bin/java-petstore.sh
./bin/java-petstore-jersey2.sh
./bin/java-petstore-okhttp-gson.sh
./bin/java-petstore-retrofit.sh
./bin/jaxrs-petstore-server.sh
./bin/nodejs-petstore-server.sh
./bin/objc-petstore.sh
./bin/perl-petstore.sh
./bin/php-petstore.sh
./bin/python-petstore.sh
./bin/python3-petstore.sh
./bin/qt5-petstore.sh
./bin/retrofit-petstore.sh
./bin/ruby-petstore.sh
./bin/scala-async-petstore.sh
./bin/scala-petstore.sh
Expand Down
2 changes: 1 addition & 1 deletion bin/python3-petstore.sh → bin/dart-petstore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/python3 -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l python3 -o samples/client/petstore/python3"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l dart -o samples/client/petstore/dart"

java $JAVA_OPTS -jar $executable $ags
4 changes: 4 additions & 0 deletions bin/java-petstore-okhttp-gson.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"library": "okhttp-gson",
"artifactId": "swagger-petstore-okhttp-gson"
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/retrofit -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l retrofit -o samples/client/petstore/retrofit"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-okhttp-gson.json -o samples/client/petstore/java/okhttp-gson"

java $JAVA_OPTS -jar $executable $ags
4 changes: 4 additions & 0 deletions bin/java-petstore-retrofit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"library": "retrofit",
"artifactId": "swagger-petstore-retrofit"
}
31 changes: 31 additions & 0 deletions bin/java-petstore-retrofit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

SCRIPT="$0"

while [ -h "$SCRIPT" ] ; do
ls=`ls -ld "$SCRIPT"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
SCRIPT="$link"
else
SCRIPT=`dirname "$SCRIPT"`/"$link"
fi
done

if [ ! -d "${APP_DIR}" ]; then
APP_DIR=`dirname "$SCRIPT"`/..
APP_DIR=`cd "${APP_DIR}"; pwd`
fi

executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"

if [ ! -f "$executable" ]
then
mvn clean package
fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l java -c bin/java-petstore-retrofit.json -o samples/client/petstore/java/retrofit"

java $JAVA_OPTS -jar $executable $ags
Loading

0 comments on commit 09f6099

Please sign in to comment.