I have a project that needs to use multiple swagger yaml definitions, one per microservice, but the Maven code gen plugin doesn't appear to support multiple inputSpec, or if it does isn't included in the maven plugin examples.
In my case the output language, library, packages etc are all the same, I just need to be able to specify multiple definition files, so just allowing multiple paths in the inputSpec string could be a quick win however future improvements should consider that all settings may need to be specified per definition file.
I'm not sure if this helps in your case, but you could simply add multiple executions of the maven plugin into your pom.
Example based on README.md:
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.1.5-SNAPSHOT</version>
<executions>
<execution>
<id>first-service-api</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/firstServiceApi.yaml</inputSpec>
<language>java</language>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
</configOptions>
</configuration>
</execution>
<execution>
<id>second-service-api</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>src/main/resources/secondServiceApi.yaml</inputSpec>
<language>java</language>
<configOptions>
<sourceFolder>src/gen/java/main</sourceFolder>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
(You can also put common configuration options into plugin → configuration instead of repeating them for each execution.)
Ah thanks, I should have realised that :/
the problem i am facing is both the apis classes generated has same io.swagger.model package and i have same class names. how to generate them with package being custom say com.src.api1.model and com.src.api2.model
for example RequestCreate.java is created in both sourcefolders but when i try to import them in code both have package io.swagger.model;
the problem i am facing is both the apis classes generated has same io.swagger.model package and i have same class names. how to generate them with package being custom say com.src.api1.model and com.src.api2.model
for example RequestCreate.java is created in both sourcefolders but when i try to import them in code both have package io.swagger.model;
<execution>
<id>spring-gen</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/api/test.yaml</inputSpec>
<generatorName>spring</generatorName>
<output>${generated.dir.spring}</output>
<apiPackage>${package.base}.api</apiPackage>
<modelPackage>${package.base}.model</modelPackage>
<invokerPackage>${package.base}.invoker</invokerPackage>
<configOptions>
<sourceFolder>src/main/java</sourceFolder>
</configOptions>
</configuration>
</execution>
Try different "apiPackage", "modelPackage", "invokerPackage" configs for different execution.
Most helpful comment
I'm not sure if this helps in your case, but you could simply add multiple executions of the maven plugin into your pom.
Example based on README.md:
(You can also put common configuration options into plugin → configuration instead of repeating them for each execution.)