为同一项目中的多个swagger生成代码

时间:2017-01-17 16:42:58

标签: json swagger swagger-codegen

如何在一个pom.xml中的同一模块/项目中为多个swagger文件生成代码。

在我的应用程序中,客户端提供了一个招摇,我们有一个后端API被调用,他们提供了swagger。我想在同一个项目中为这两个代码生成代码。我想的一种方法是创建单独的模块并单独执行插件,并在主模块中调用这些依赖项。

如何从一个构建插件生成代码?如果它是转贴,请指出我现有的。我找不到任何东西。

这是我在pom.xml中配置的插件

 <plugin>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-codegen-maven-plugin</artifactId>
            <version>2.2.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                      <inputSpec>${project.basedir}/src/main/ resources/Service.json</inputSpec><inputSpec>${project.basedir}/src /main/resources/Client.json</inputSpec>
                        <language>java</language>
                        <configOptions>
                            <dateLibrary>java8</dateLibrary>
                        </configOptions>
                        <modelPackage>com.service.model</modelPackage>
                        <environmentVariables>
                            <models/>
                            <supportingFiles>false</supportingFiles>
                        </environmentVariables>
                    </configuration>
                </execution>
            </executions>
        </plugin>

也试过* .json。在任何时候它只需要一个json文件并生成代码。

1 个答案:

答案 0 :(得分:2)

为了做到这一点,你可以为每个json文件声明一个不同的执行,每个json文件应该有一个唯一的id。

以下是两个执行的示例,undefined用于文件 first.json execution-first-json用于文件 second.json

execution-second-json