Generating Java/Spring Server-Stubs with swagger-codegen-maven-plugin
In my Spring Boot Java project, I utilize the swagger-codegen-maven-plugin to automatically generate the server stubs for Spring MVC controller interfaces from my Swagger 2.0 api.yml file. The integration into the Maven build process is straightforward and resembles how I used to work with the jaxws-maven-plugin for WSDLs. Below is an example configuration snippet from my pom.xml file using swagger-codegen to produce the server-side models and MVC interfaces:
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.2.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>/api/api-v2.yml</inputSpec>
<language>spring</language>
<apiPackage>io.fischermatte.test.api</apiPackage>
<modelPackage>io.fischermatte.test.api.model</modelPackage>
<output>${project.build.directory}/generated</output>
<configOptions>
<interfaceOnly>true</interfaceOnly>
<sourceFolder>/src/main/java</sourceFolder>
<library>spring-mvc</library>
<dateLibrary>java8</dateLibrary>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Integrating Client Code Generation in a npm Build Process
Now, I am exploring ways to incorporate the generation of client code within the npm build process of my Angular app. I have an api.yml file that outlines my REST endpoints following the Swagger 2.0 specification. My goal is to have the npm build create the API module similar to the typescript-angular-v4.3 sample. From what I've observed, there isn't an official npm package that mirrors the functionality of swagger-codegen-maven-plugin when working with Maven.
Am I missing something here? The mentioned sample appears to achieve the desired outcome, but what is the recommended approach to reach that point? Is integrating this process into an npm-based project not advisable? Should one resort to manual generation and inclusion of the generated TypeScript files into the source directory?