-
Notifications
You must be signed in to change notification settings - Fork 6k
Workflow integration
Default codegen templates are included with the swagger-codegen artifact. You can of course override these by copying them into your own deployment, and setting a new template directory. A good starting point is to grab templates from here:
https://github.com/wordnik/swagger-codegen/tree/master/src/main/resources
And modify them as you like. After doing so, you'll need to override the basic codegen template directory. See the petstore client as an example:
https://github.com/wordnik/swagger-codegen/tree/master/samples/client/petstore
// location of templates
override def templateDir = "mytemplates/Java"
It's easy to make the codegen a part of your build cycle. Take the following pom.xml
for example:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wordnik</groupId>
<artifactId>client-generator</artifactId>
<packaging>jar</packaging>
<name>client-generator</name>
<version>1.0.0-SNAPSHOT</version>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${maven-plugin-version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmArgs>
<jvmArg>-Xms64m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
</jvmArgs>
<launchers>
<launcher>
<id>codegen</id>
<!-- See note #1 -->
<mainClass>JavaPetstoreCodegen</mainClass>
<args>
<!-- See note #2 -->
<arg>http://petstore.swagger.wordnik.com/api/api-docs.json</arg>
<arg>special-key</arg>
<arg></arg>
</args>
<jvmArgs>
<!-- See note #3 -->
<jvmArg>-DfileMap=src/test/resources/</jvmArg>
</jvmArgs>
</launcher>
</launchers>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<!-- See note #4 -->
<repository>
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.wordnik</groupId>
<artifactId>swagger-codegen_2.9.1</artifactId>
<version>${codegen-version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala-version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
<properties>
<codegen-version>2.0.3-SNAPSHOT</codegen-version>
<scala-version>2.9.1-1</scala-version>
<junit-version>4.8.1</junit-version>
<maven-plugin-version>3.1.0</maven-plugin-version>
</properties>
</project>
would suggest when compiling to use flag to ignore tests. The tests requires extra dependencies and the compilation might fail due to that.