Skip to content

Instantly share code, notes, and snippets.

@fehguy
Created January 30, 2017 21:48
Show Gist options
  • Save fehguy/ce8019c8d1335d21a5721090e48b4ef6 to your computer and use it in GitHub Desktop.
Save fehguy/ce8019c8d1335d21a5721090e48b4ef6 to your computer and use it in GitHub Desktop.
sample pom.xml for generating code with swagger-codegen in-line
<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.my.org</groupId>
<artifactId>my-project</artifactId>
<packaging>jar</packaging>
<name>my-project</name>
<version>1.0.0</version>
<prerequisites>
<maven>2.2.0</maven>
</prerequisites>
<profiles>
<!-- generates a client -->
<profile>
<id>generate-client</id>
<build>
<plugins>
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${codegen.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>swagger.json</inputSpec>
<language>java</language>
<configOptions>
<!-- write files to src/gen/java -->
<sourceFolder>src/gen/java</sourceFolder>
</configOptions>
<!-- output directory is cwd (this project) -->
<output>.</output>
<!-- override the model packaging -->
<modelPackage>org.my.org.models</modelPackage>
</configuration>
</execution>
</executions>
<dependencies>
<!-- add additional deps here, like custom templates -->
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<!-- add dependencies needed for this profile -->
</dependencies>
</profile>
</profiles>
<dependencies>
<!-- normal projecct dependencies -->
</dependencies>
<repositories>
<repository>
<!-- enable sonatype snapshots to get the latest -->
<id>sonatype-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<properties>
<codegen.version>2.2.1</codegen.version>
</properties>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment