Skip to content

Commit 915ad77

Browse files
committed
Merge branch 'develop_2.0'
2 parents ca46405 + f025dda commit 915ad77

File tree

1,095 files changed

+96241
-59969
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,095 files changed

+96241
-59969
lines changed

.gitignore

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,22 @@ samples/server-generator/scalatra/output
2222
samples/server-generator/node/output/node_modules
2323
samples/server-generator/scalatra/target
2424
samples/server-generator/scalatra/output/.history
25-
25+
samples/client/petstore/qt5cpp/PetStore/moc_*
26+
samples/client/petstore/qt5cpp/PetStore/*.o
27+
samples/client/petstore/objc/PetstoreClient.xcworkspace/xcuserdata
28+
samples/client/petstore/qt5cpp/build-*
29+
samples/client/petstore/qt5cpp/PetStore/PetStore
30+
samples/client/petstore/qt5cpp/PetStore/Makefile
31+
samples/client/petstore/java/hello.txt
32+
samples/client/petstore/android-java/hello.txt
33+
samples/client/petstore/objc/Build
34+
samples/client/petstore/objc/Pods
35+
samples/server/petstore/nodejs/node_modules
2636
target
2737
.idea
2838
.lib
2939
atlassian-ide-plugin.xml
3040
.DS_Store
41+
42+
samples/client/petstore/php/SwaggerClient-php/composer.lock
43+
samples/client/petstore/php/SwaggerClient-php/vendor/

README.md

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ The Swagger Specification has undergone 3 revisions since initial creation in 20
1313

1414
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
1515
----------------------- | ------------ | -------------------------- | -----
16-
2.1.0-M2 | 2015-04-06 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
17-
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/2.0.17)
16+
2.1.0 | 2015-06-09 | 1.0, 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-codegen)
17+
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)
1818
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)
1919

2020

@@ -66,6 +66,8 @@ NAME
6666
6767
SYNOPSIS
6868
swagger generate [(-a <authorization> | --auth <authorization>)]
69+
[(-c <configuration file> | --config <configuration file>)]
70+
[-D <system properties>]
6971
(-i <spec file> | --input-spec <spec file>)
7072
(-l <language> | --lang <language>)
7173
[(-o <output directory> | --output <output directory>)]
@@ -78,6 +80,16 @@ OPTIONS
7880
remotely. Pass in a URL-encoded string of name:header with a comma
7981
separating multiple values
8082
83+
-c <configuration file>, --config <configuration file>
84+
Path to json configuration file. File content should be in a json
85+
format {"optionKey":"optionValue", "optionKey1":"optionValue1"...}
86+
Supported options can be different for each language. Run
87+
config-help -l {lang} command for language specific config options.
88+
89+
-D <system properties>
90+
sets specified system properties in the format of
91+
name=value,name=value
92+
8193
-i <spec file>, --input-spec <spec file>
8294
location of the swagger spec, as URL or file (required)
8395
@@ -148,16 +160,21 @@ Great for creating libraries on your ci server, from the [Swagger Editor](http:/
148160
There are different aspects of customizing the code generator beyond just creating or modifying templates. Each language has a supporting configuration file to handle different type mappings, etc:
149161

150162
```
151-
$ ls -1 modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/
163+
$ ls -1 modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/
164+
AkkaScalaClientCodegen.java
152165
AndroidClientCodegen.java
153166
AsyncScalaClientCodegen.java
154167
CSharpClientCodegen.java
155168
JavaClientCodegen.java
156169
JaxRSServerCodegen.java
157170
NodeJSServerCodegen.java
158171
ObjcClientCodegen.java
172+
PerlClientCodegen.java
159173
PhpClientCodegen.java
174+
Python3ClientCodegen.java
160175
PythonClientCodegen.java
176+
Qt5CPPGenerator.java
177+
RetrofitClientCodegen.java
161178
RubyClientCodegen.java
162179
ScalaClientCodegen.java
163180
ScalatraServerCodegen.java
@@ -166,17 +183,70 @@ StaticDocCodegen.java
166183
StaticHtmlGenerator.java
167184
SwaggerGenerator.java
168185
SwaggerYamlGenerator.java
186+
SwiftGenerator.java
169187
TizenClientCodegen.java
170188
```
171189

172-
Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc., you may want to extend these.
190+
Each of these files creates reasonable defaults so you can get running quickly. But if you want to configure package names, prefixes, model folders, etc. you can use a json config file to pass the values.
191+
192+
```
193+
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
194+
-i http://petstore.swagger.io/v2/swagger.json \
195+
-l java \
196+
-o samples/client/petstore/java \
197+
-c path/to/config.json
198+
```
199+
Supported config options can be different per language. Running `config-help -l {lang}` will show available options.
200+
201+
```
202+
java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jarr config-help -l java
203+
```
204+
205+
Output
206+
207+
```
208+
CONFIG OPTIONS
209+
modelPackage
210+
package for generated models
211+
212+
apiPackage
213+
package for generated api classes
214+
215+
invokerPackage
216+
root package for generated code
217+
218+
groupId
219+
groupId in generated pom.xml
220+
221+
artifactId
222+
artifactId in generated pom.xml
223+
224+
artifactVersion
225+
artifact version in generated pom.xml
226+
227+
sourceFolder
228+
source folder for generated code
229+
```
230+
231+
Your config file for java can look like
232+
233+
```
234+
{
235+
"groupId":"com.my.company",
236+
"artifactId":"MyClent",
237+
"artifactVersion":"1.2.0"
238+
}
239+
```
240+
241+
For all the unspecified options default values will be used.
173242

243+
Another way to override default options is to extend config class for specific language.
174244
To change, for example, the prefix for the Objective-C generated files, simply subclass the ObjcClientCodegen.java:
175245

176246
```
177247
package com.mycompany.swagger.codegen;
178248
179-
import com.wordnik.swagger.codegen.languages.*;
249+
import io.swagger.codegen.languages.*;
180250
181251
public class MyObjcCodegen extends ObjcClientCodegen {
182252
static {

bin/akka-scala-petstore.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
ags="$@ generate -t modules/swagger-codegen/src/main/resources/akka-scala -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l akka-scala -o samples/client/petstore/akka-scala"
30+
31+
java $JAVA_OPTS -jar $executable $ags

bin/all-petstore.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ cd $APP_DIR
2424
./bin/html-petstore.sh
2525
./bin/jaxrs-petstore-server.sh
2626
./bin/java-petstore.sh
27+
./bin/qt5-petstore.sh
2728
./bin/php-petstore.sh
2829
./bin/python-petstore.sh
30+
./bin/retrofit-petstore.sh
2931
./bin/ruby-petstore.sh
3032
./bin/objc-petstore.sh
3133
./bin/scala-petstore.sh

bin/jaxrs-petstore-server.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ fi
2626

2727
# if you've executed sbt assembly previously it will use that instead.
2828
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29-
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs -o samples/server/petstore/jaxrs"
29+
ags="$@ generate -t modules/swagger-codegen/src/main/resources/JavaJaxRS -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l jaxrs -o samples/server/petstore/jaxrs -Dswagger.codegen.jaxrs.impl.source=src/main/java"
3030

3131
java $JAVA_OPTS -jar $executable $ags

bin/perl-petstore.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l perl -o samples/client/petstore/perl"
30+
31+
java $JAVA_OPTS -jar $executable $ags

bin/python3-petstore.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
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"
30+
31+
java $JAVA_OPTS -jar $executable $ags

bin/qt5-petstore.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
ags="$@ generate -t modules/swagger-codegen/src/main/resources/qt5cpp -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l qt5cpp -o samples/client/petstore/qt5cpp"
30+
31+
java $JAVA_OPTS -jar $executable $ags

bin/retrofit-petstore.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
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"
30+
31+
java $JAVA_OPTS -jar $executable $ags

bin/swift-petstore.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
ags="$@ generate -t modules/swagger-codegen/src/main/resources/swift -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l swift -o samples/client/petstore/swift"
30+
31+
java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags

0 commit comments

Comments
 (0)