Swagger-codegen: Generate code for multiple swaggers in the same project

Created on 16 Jan 2017  路  2Comments  路  Source: swagger-api/swagger-codegen

Hi,
How do i generate code for multiple swagger files from within the same module/project in one pom.xml.

In my application client had provided a swagger and we have one of the backend API to be called for which they provided swagger. I want to generate code for both of these in the same project. One way i was thinking is create separate module and execute the plugin separately and have those dependencies called out in main module.

How do i generate code from one build plugin? Please point me to existing one if it is a repost. I couldn't find any.

Question Swagger Codegen Maven Plugin

Most helpful comment

You can use multiple executions.

```pom

io.swagger
swagger-codegen-maven-plugin
${swagger-codegen-maven-plugin-version}


generate-java8-jersey2-oauth

generate


${project.basedir}/../../openapi/oauth-openapi.json
java
com.xx.yy.api
com.xx.yy.model

jersey2
joda

${project.build.directory}/generated-sources/openapi



generate-java8-jersey2-client

generate


${project.basedir}/../../openapi/client-openapi.json
java
com.xx.yy.api
com.xx.yy.model

jersey2
joda

${project.build.directory}/generated-sources/openapi



All 2 comments

You can use multiple executions.

```pom

io.swagger
swagger-codegen-maven-plugin
${swagger-codegen-maven-plugin-version}


generate-java8-jersey2-oauth

generate


${project.basedir}/../../openapi/oauth-openapi.json
java
com.xx.yy.api
com.xx.yy.model

jersey2
joda

${project.build.directory}/generated-sources/openapi



generate-java8-jersey2-client

generate


${project.basedir}/../../openapi/client-openapi.json
java
com.xx.yy.api
com.xx.yy.model

jersey2
joda

${project.build.directory}/generated-sources/openapi



Is there a way to reuse the models?

sharebleModels.yaml
  - Customer
specA.yaml
  - "/sharebleModels.yaml#/Customer"

Or is this a feature of the 3.0?

Was this page helpful?
0 / 5 - 0 ratings