Skip to content

Instantly share code, notes, and snippets.

@starstuck
Last active April 3, 2019 14:39
Show Gist options
  • Save starstuck/91ca098b01691f582d035828f3417616 to your computer and use it in GitHub Desktop.
Save starstuck/91ca098b01691f582d035828f3417616 to your computer and use it in GitHub Desktop.
Example of maven to download and invoke swagger codegen
<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.example</groupId>
<artifactId>my-project</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-cli</artifactId>
<version>2.4.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>io.swagger.codegen.SwaggerCodegen</mainClass>
<additionalClasspathElements>
<additionalClasspathElement>${basedir}</additionalClasspathElement>
</additionalClasspathElements>
<arguments>
<argument>generate</argument>
<argument>--config</argument>
<argument>swagger-config.json</argument>
<argument>--input-spec</argument>
<argument>swagger.yaml</argument>
<argument>--lang</argument>
<argument>typescript-fetch</argument>
<argument>--output</argument>
<argument>src/api-client</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment