forked from loafle/openapi-generator-original
added spring-mvc sample
This commit is contained in:
parent
568ca26747
commit
02fd96a24a
@ -29,4 +29,5 @@ cd $APP_DIR
|
|||||||
./bin/ruby-petstore.sh
|
./bin/ruby-petstore.sh
|
||||||
./bin/objc-petstore.sh
|
./bin/objc-petstore.sh
|
||||||
./bin/scala-petstore.sh
|
./bin/scala-petstore.sh
|
||||||
|
./bin/spring-mvc-petstore-server.sh
|
||||||
./bin/tizen-petstore.sh
|
./bin/tizen-petstore.sh
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
#!/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 -t modules/swagger-codegen/src/main/resources/JavaSpringfox -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l springfox -o samples/server/petstore/springfox"
|
|
||||||
|
|
||||||
java $JAVA_OPTS -jar $executable $ags
|
|
@ -253,10 +253,20 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
|||||||
writeToFile(outputFilename, tmpl.execute(bundle));
|
writeToFile(outputFilename, tmpl.execute(bundle));
|
||||||
files.add(new File(outputFilename));
|
files.add(new File(outputFilename));
|
||||||
} else {
|
} else {
|
||||||
InputStream in = this.getClass().getClassLoader().getResourceAsStream(config.templateDir() + File.separator + support.templateFile);
|
InputStream in = new FileInputStream(config.templateDir() + File.separator + support.templateFile);
|
||||||
|
if(in == null) {
|
||||||
|
in = this.getClass().getClassLoader().getResourceAsStream(config.templateDir() + File.separator + support.templateFile);
|
||||||
|
}
|
||||||
File outputFile = new File(outputFilename);
|
File outputFile = new File(outputFilename);
|
||||||
OutputStream out = new FileOutputStream(outputFile);
|
OutputStream out = new FileOutputStream(outputFile, true);
|
||||||
IOUtils.copy(in,out);
|
if(in != null && out != null)
|
||||||
|
IOUtils.copy(in,out);
|
||||||
|
else {
|
||||||
|
if(in == null)
|
||||||
|
System.out.println("can't open " + config.templateDir() + File.separator + support.templateFile + " for input");
|
||||||
|
if(out == null)
|
||||||
|
System.out.println("can't open " + outputFile + " for output");
|
||||||
|
}
|
||||||
|
|
||||||
files.add(outputFile);
|
files.add(outputFile);
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import java.io.File;
|
|||||||
public class SpringMVCServerCodegen extends JavaClientCodegen implements CodegenConfig {
|
public class SpringMVCServerCodegen extends JavaClientCodegen implements CodegenConfig {
|
||||||
protected String invokerPackage = "io.swagger.api";
|
protected String invokerPackage = "io.swagger.api";
|
||||||
protected String groupId = "io.swagger";
|
protected String groupId = "io.swagger";
|
||||||
protected String artifactId = "swagger-server";
|
protected String artifactId = "swagger-spring-mvc-server";
|
||||||
protected String artifactVersion = "1.0.0";
|
protected String artifactVersion = "1.0.0";
|
||||||
protected String sourceFolder = "src/main/java";
|
protected String sourceFolder = "src/main/java";
|
||||||
protected String title = "Petstore Server";
|
protected String title = "Petstore Server";
|
||||||
|
@ -22,7 +22,7 @@ public class SwaggerConfig {
|
|||||||
ApiInfo apiInfo() {
|
ApiInfo apiInfo() {
|
||||||
ApiInfo apiInfo = new ApiInfo(
|
ApiInfo apiInfo = new ApiInfo(
|
||||||
"{{appName}}",
|
"{{appName}}",
|
||||||
"{{appDescription}}",
|
"{{{appDescription}}}",
|
||||||
"{{appVersion}}",
|
"{{appVersion}}",
|
||||||
"{{infoUrl}}",
|
"{{infoUrl}}",
|
||||||
"{{infoEmail}}",
|
"{{infoEmail}}",
|
||||||
|
13
pom.xml
13
pom.xml
@ -338,6 +338,18 @@
|
|||||||
<module>samples/client/petstore/ruby</module>
|
<module>samples/client/petstore/ruby</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>spring-mvc</id>
|
||||||
|
<activation>
|
||||||
|
<property>
|
||||||
|
<name>env</name>
|
||||||
|
<value>java</value>
|
||||||
|
</property>
|
||||||
|
</activation>
|
||||||
|
<modules>
|
||||||
|
<module>samples/server/petstore/spring-mvc</module>
|
||||||
|
</modules>
|
||||||
|
</profile>
|
||||||
<profile>
|
<profile>
|
||||||
<id>samples</id>
|
<id>samples</id>
|
||||||
<activation>
|
<activation>
|
||||||
@ -350,6 +362,7 @@
|
|||||||
<module>samples/client/petstore/android-java</module>
|
<module>samples/client/petstore/android-java</module>
|
||||||
<module>samples/client/petstore/java</module>
|
<module>samples/client/petstore/java</module>
|
||||||
<module>samples/server/petstore/jaxrs</module>
|
<module>samples/server/petstore/jaxrs</module>
|
||||||
|
<module>samples/server/petstore/spring-mvc</module>
|
||||||
<module>samples/client/petstore/objc</module>
|
<module>samples/client/petstore/objc</module>
|
||||||
<module>samples/client/petstore/ruby</module>
|
<module>samples/client/petstore/ruby</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user