Skip to content

Commit 6d58d44

Browse files
committed
Merge branch 'ruby-api-client' into ruby-apiclient
2 parents 7be6e97 + 0e2e783 commit 6d58d44

File tree

268 files changed

+12866
-5695
lines changed

Some content is hidden

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

268 files changed

+12866
-5695
lines changed

.dockerignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
*.iml
2+
out/
3+
*.ipr
4+
*.iws
5+
classpath.txt
6+
version.properties
7+
.project
8+
.classpath
9+
lib/*
10+
build/*
11+
generated-files/*
12+
generated-sources/*
13+
generated-code/*
14+
*.swp
15+
*.swo
16+
17+
/target
18+
/generated-files
19+
/nbactions.xml
20+
*.pyc
21+
__pycache__
22+
samples/server-generator/scalatra/output
23+
samples/server-generator/node/output/node_modules
24+
samples/server-generator/scalatra/target
25+
samples/server-generator/scalatra/output/.history
26+
samples/client/petstore/qt5cpp/PetStore/moc_*
27+
samples/client/petstore/qt5cpp/PetStore/*.o
28+
samples/client/petstore/objc/PetstoreClient.xcworkspace/xcuserdata
29+
samples/client/petstore/qt5cpp/build-*
30+
samples/client/petstore/qt5cpp/PetStore/PetStore
31+
samples/client/petstore/qt5cpp/PetStore/Makefile
32+
samples/client/petstore/java/hello.txt
33+
samples/client/petstore/android-java/hello.txt
34+
samples/client/petstore/objc/Build
35+
samples/client/petstore/objc/Pods
36+
samples/server/petstore/nodejs/node_modules
37+
target
38+
.idea
39+
.lib
40+
atlassian-ide-plugin.xml
41+
.DS_Store
42+
43+
samples/client/petstore/php/SwaggerClient-php/composer.lock
44+
samples/client/petstore/php/SwaggerClient-php/vendor/
45+
46+
samples/client/petstore/silex/SwaggerServer/composer.lock
47+
samples/client/petstore/silex/SwaggerServer/venodr/

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM maven:3.3-jdk-7
2+
3+
WORKDIR /src
4+
VOLUME /src
5+
VOLUME /root/.m2/repository
6+
7+
ADD . /opt/swagger-codegen
8+
9+
RUN cd /opt/swagger-codegen && mvn package
10+
11+
ENTRYPOINT ["java", "-jar", "/opt/swagger-codegen/modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"]
12+
13+
CMD ["help"]

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ This is the swagger codegen project, which allows generation of client libraries
77

88
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.
99

10+
## Build and run using docker
11+
12+
```
13+
git clone https://github.com/swagger-api/swagger-codegen
14+
15+
cd swagger-codegen
16+
17+
./run-in-docker.sh mvn package
18+
```
19+
20+
Build a nodejs server stub:
21+
22+
```
23+
./run-in-docker.sh generate \
24+
-i http://petstore.swagger.io/v2/swagger.json \
25+
-l nodejs \
26+
-o samples/server/petstore/nodejs
27+
```
1028

1129
## Compatibility
1230
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the swagger specification:
@@ -170,6 +188,7 @@ AkkaScalaClientCodegen.java
170188
AndroidClientCodegen.java
171189
AsyncScalaClientCodegen.java
172190
CSharpClientCodegen.java
191+
FlashClientCodegen.java
173192
JavaClientCodegen.java
174193
JaxRSServerCodegen.java
175194
NodeJSServerCodegen.java

bin/csharp-dotnet2-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 CsharpDotNet2 -o samples/client/petstore/csharp-dotnet2/SwaggerClientTest/Lib/SwaggerClient"
30+
31+
java $JAVA_OPTS -jar $executable $ags

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

modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,24 @@
1616
* limitations under the License.
1717
*/
1818

19+
import io.swagger.codegen.CliOption;
1920
import io.swagger.codegen.ClientOptInput;
2021
import io.swagger.codegen.ClientOpts;
2122
import io.swagger.codegen.CodegenConfig;
2223
import io.swagger.codegen.DefaultGenerator;
2324
import io.swagger.models.Swagger;
2425
import io.swagger.parser.SwaggerParser;
26+
2527
import org.apache.maven.plugin.AbstractMojo;
2628
import org.apache.maven.plugin.MojoExecutionException;
2729
import org.apache.maven.plugins.annotations.LifecyclePhase;
2830
import org.apache.maven.plugins.annotations.Mojo;
2931
import org.apache.maven.plugins.annotations.Parameter;
3032
import org.apache.maven.project.MavenProject;
3133

34+
import config.Config;
35+
import config.ConfigParser;
36+
3237
import java.io.File;
3338
import java.util.ServiceLoader;
3439

@@ -66,6 +71,12 @@ public class CodeGenMojo extends AbstractMojo {
6671
@Parameter(name = "language", required = true)
6772
private String language;
6873

74+
/**
75+
* Path to json configuration file.
76+
*/
77+
@Parameter(name = "configurationFile", required = false)
78+
private String configurationFile;
79+
6980

7081
/**
7182
* Add the output directory to the project as a source root, so that the
@@ -90,7 +101,20 @@ public void execute() throws MojoExecutionException {
90101
if (null != templateDirectory) {
91102
config.additionalProperties().put(TEMPLATE_DIR_PARAM, templateDirectory.getAbsolutePath());
92103
}
93-
104+
105+
if (null != configurationFile) {
106+
Config genConfig = ConfigParser.read(configurationFile);
107+
if (null != genConfig) {
108+
for (CliOption langCliOption : config.cliOptions()) {
109+
if (genConfig.hasOption(langCliOption.getOpt())) {
110+
config.additionalProperties().put(langCliOption.getOpt(), genConfig.getOption(langCliOption.getOpt()));
111+
}
112+
}
113+
} else {
114+
throw new RuntimeException("Unable to read configuration file");
115+
}
116+
}
117+
94118
ClientOptInput input = new ClientOptInput().opts(new ClientOpts()).swagger(swagger);
95119
input.setConfig(config);
96120
new DefaultGenerator().opts(input).generate();

modules/swagger-codegen/pom.xml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@
8383
</execution>
8484
</executions>
8585
<configuration>
86-
<configuration>
87-
<recompileMode>incremental</recompileMode>
88-
</configuration>
86+
<recompileMode>incremental</recompileMode>
8987
<jvmArgs>
9088
<jvmArg>-Xmx384m</jvmArg>
9189
</jvmArgs>
@@ -149,14 +147,6 @@
149147
<artifactId>scala-maven-plugin</artifactId>
150148
<version>${scala-maven-plugin-version}</version>
151149
</plugin>
152-
<plugin>
153-
<groupId>org.apache.maven.plugins</groupId>
154-
<artifactId>maven-gpg-plugin</artifactId>
155-
<configuration>
156-
<releaseProfiles>release</releaseProfiles>
157-
<goals>sign</goals>
158-
</configuration>
159-
</plugin>
160150
</plugins>
161151
</pluginManagement>
162152
</build>
@@ -180,7 +170,7 @@
180170
</execution>
181171
</executions>
182172
<configuration>
183-
<scala-version>${scala-version}</scala-version>
173+
<scalaVersion>${scala-version}</scalaVersion>
184174
</configuration>
185175
</plugin>
186176
<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
@@ -65,6 +65,8 @@ public interface CodegenConfig {
6565

6666
CodegenModel fromModel(String name, Model model);
6767

68+
CodegenModel fromModel(String name, Model model, Map<String, Model> allDefinitions);
69+
6870
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Model> definitions);
6971

7072
List<CodegenSecurity> fromSecurity(Map<String, SecuritySchemeDefinition> schemes);

0 commit comments

Comments
 (0)