Skip to content

Commit 358e5a4

Browse files
committed
Merge remote-tracking branch '9845/master' into 9845
2 parents 5d00b34 + 621dfc0 commit 358e5a4

File tree

116 files changed

+8295
-223
lines changed

Some content is hidden

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

116 files changed

+8295
-223
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -928,6 +928,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
928928
- [Mporium](http://mporium.com/)
929929
- [Neverfail](https://neverfail.com/)
930930
- [NexCap](http://www.nexess-solutions.com/fr/plateforme-iot/)
931+
- [Norwegian Air Shuttle](https://www.norwegian.com/)
931932
- [NTT DATA](http://www.nttdata.com/)
932933
- [nViso](http://www.nviso.ch/)
933934
- [Okiok](https://www.okiok.com)
@@ -992,6 +993,7 @@ Here are some companies/projects using Swagger Codegen in production. To add you
992993
- [Zalando](https://tech.zalando.com)
993994
- [ZEEF.com](https://zeef.com/)
994995
- [zooplus](https://www.zooplus.com/)
996+
- [Trifork](https://www.trifork.com/)
995997

996998
Presentations/Videos/Tutorials/Books
997999
----------------------------------------
@@ -1177,7 +1179,7 @@ Who is eligible? Those who want to join must have at least 3 PRs merged into a g
11771179
| Android | |
11781180
| Apex | |
11791181
| Bash | @kenjones-cisco (2017/09) |
1180-
| C++ | @fvarose (2017/11) |
1182+
| C++ | |
11811183
| C# | @mandrean (2017/08) |
11821184
| Clojure | |
11831185
| Dart | @ircecho (2017/07) |

bin/security/ue4cpp-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/ue4cpp -i modules/swagger-codegen/src/test/resources/2_0/petstore-security-test.yaml -l ue4cpp -o samples/client/petstore-security-test/ue4cpp"
30+
31+
java $JAVA_OPTS -jar $executable $ags

bin/ue4cpp-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/ue4cpp -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l ue4cpp -o samples/client/petstore/ue4cpp"
30+
31+
java $JAVA_OPTS -jar $executable $ags

bin/windows/ue4cpp-petstore.bat

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
2+
3+
If Not Exist %executable% (
4+
mvn clean package
5+
)
6+
7+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
8+
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l ue4cpp -o samples\client\petstore\ue4cpp
9+
10+
java %JAVA_OPTS% -jar %executable% %ags%

modules/swagger-codegen-cli/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger</groupId>
55
<artifactId>swagger-codegen-project</artifactId>
6-
<version>2.4.14</version>
6+
<version>2.4.15-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>

modules/swagger-codegen-maven-plugin/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>io.swagger</groupId>
66
<artifactId>swagger-codegen-project</artifactId>
7-
<version>2.4.14</version>
7+
<version>2.4.15-SNAPSHOT</version>
88
<relativePath>../..</relativePath>
99
</parent>
1010
<artifactId>swagger-codegen-maven-plugin</artifactId>

modules/swagger-codegen/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<parent>
44
<groupId>io.swagger</groupId>
55
<artifactId>swagger-codegen-project</artifactId>
6-
<version>2.4.14</version>
6+
<version>2.4.15-SNAPSHOT</version>
77
<relativePath>../..</relativePath>
88
</parent>
99
<modelVersion>4.0.0</modelVersion>
@@ -74,8 +74,8 @@
7474
<artifactId>maven-compiler-plugin</artifactId>
7575
<version>3.5.1</version>
7676
<configuration>
77-
<source>1.7</source>
78-
<target>1.7</target>
77+
<source>1.8</source>
78+
<target>1.8</target>
7979
</configuration>
8080
</plugin>
8181
<plugin>

modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConfig.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ public interface CodegenConfig {
163163

164164
String apiFilename(String templateName, String tag);
165165

166+
String modelFilename(String templateName, String modelName);
167+
166168
String apiTestFilename(String templateName, String tag);
167169

168170
String apiDocFilename(String templateName, String tag);

modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -190,43 +190,48 @@ public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
190190
allModels.put(modelName, cm);
191191
}
192192
}
193-
// Fix up all parent and interface CodegenModel references.
194-
for (CodegenModel cm : allModels.values()) {
195-
if (cm.parent != null) {
196-
cm.parentModel = allModels.get(cm.parent);
197-
}
198-
if (cm.interfaces != null && !cm.interfaces.isEmpty()) {
199-
cm.interfaceModels = new ArrayList<CodegenModel>(cm.interfaces.size());
200-
for (String intf : cm.interfaces) {
201-
CodegenModel intfModel = allModels.get(intf);
202-
if (intfModel != null) {
203-
cm.interfaceModels.add(intfModel);
204-
}
205-
}
206-
}
207-
}
208-
// Let parent know about all its children
193+
209194
for (String name : allModels.keySet()) {
210-
CodegenModel cm = allModels.get(name);
211-
CodegenModel parent = allModels.get(cm.parent);
212-
// if a discriminator exists on the parent, don't add this child to the inheritance hierarchy
213-
// TODO Determine what to do if the parent discriminator name == the grandparent discriminator name
214-
while (parent != null) {
215-
if (parent.children == null) {
216-
parent.children = new ArrayList<CodegenModel>();
217-
}
218-
parent.children.add(cm);
219-
if (parent.discriminator == null) {
220-
parent = allModels.get(parent.parent);
221-
} else {
222-
parent = null;
223-
}
224-
}
195+
CodegenModel codegenModel = allModels.get(name);
196+
fixUpParentAndInterfaces(codegenModel, allModels);
225197
}
226198
}
227199
return objs;
228200
}
229201

202+
/**
203+
* Fix up all parent and interface CodegenModel references.
204+
* @param allModels
205+
*/
206+
protected void fixUpParentAndInterfaces(CodegenModel codegenModel, Map<String, CodegenModel> allModels) {
207+
if (codegenModel.parent != null) {
208+
codegenModel.parentModel = allModels.get(codegenModel.parent);
209+
}
210+
if (codegenModel.interfaces != null && !codegenModel.interfaces.isEmpty()) {
211+
codegenModel.interfaceModels = new ArrayList<CodegenModel>(codegenModel.interfaces.size());
212+
for (String intf : codegenModel.interfaces) {
213+
CodegenModel intfModel = allModels.get(intf);
214+
if (intfModel != null) {
215+
codegenModel.interfaceModels.add(intfModel);
216+
}
217+
}
218+
}
219+
CodegenModel parent = codegenModel.parentModel;
220+
// if a discriminator exists on the parent, don't add this child to the inheritance hierarchy
221+
// TODO Determine what to do if the parent discriminator name == the grandparent discriminator name
222+
while (parent != null) {
223+
if (parent.children == null) {
224+
parent.children = new ArrayList<CodegenModel>();
225+
}
226+
parent.children.add(codegenModel);
227+
if (parent.discriminator == null) {
228+
parent = allModels.get(parent.parent);
229+
} else {
230+
parent = null;
231+
}
232+
}
233+
}
234+
230235
// override with any special post-processing
231236
@SuppressWarnings("static-method")
232237
public Map<String, Object> postProcessModels(Map<String, Object> objs) {
@@ -3445,6 +3450,11 @@ public String apiFilename(String templateName, String tag) {
34453450
return apiFileFolder() + File.separator + toApiFilename(tag) + suffix;
34463451
}
34473452

3453+
public String modelFilename(String templateName, String modelName) {
3454+
String suffix = modelTemplateFiles().get(templateName);
3455+
return modelFileFolder() + File.separator + toModelFilename(modelName) + suffix;
3456+
}
3457+
34483458
/**
34493459
* Return the full path and API documentation file
34503460
*

modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,7 @@ private Model getParent(Model model) {
424424
}
425425
allModels.add(modelTemplate);
426426
for (String templateName : config.modelTemplateFiles().keySet()) {
427-
String suffix = config.modelTemplateFiles().get(templateName);
428-
String filename = config.modelFileFolder() + File.separator + config.toModelFilename(modelName) + suffix;
427+
String filename = config.modelFilename(templateName, modelName);
429428
if (!config.shouldOverwrite(filename)) {
430429
LOGGER.info("Skipped overwriting " + filename);
431430
continue;

0 commit comments

Comments
 (0)