使用没有spring-boot依赖的swagger-codegen-maven-plugin

时间:2017-07-21 14:01:18

标签: swagger swagger-codegen

我要求使用swagger生成rest api。我已经编写了用于生成Rest API的yaml文件。在我的pom.xml中我有

  

块引用

`<build>
        <plugins>
            <plugin>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.2.2</version>
                <executions>
                    <execution>
                        <id>sample-api</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>src/main/resources/swagger.yaml</inputSpec>
                            <output>src/test/java</output>
                            <language>spring</language>
                             <configOptions>
                               <sourceFolder>/</sourceFolder>
                            </configOptions>
                            <apiPackage>io.swagger.handler</apiPackage>
                            <modelPackage>io.swagger.model</modelPackage>
                            <invokerPackage>io.swagger.handler</invokerPackage>
                        </configuration>
                    </execution>
              </executions>
            </plugin>
        </plugins>
    </build>`

但是当我执行“mvn clean install”时,它会要求我提供org.springframework.boot依赖项。有没有办法可以在没有spring-boot依赖的情况下使用这个插件?

1 个答案:

答案 0 :(得分:0)

  <!-- SWAGGER -->
            <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>${basedir}/swagger.yaml</inputSpec>
                            <language>spring</language>
                            <output>${basedir}</output>
                        </configuration>
                    </execution>
                </executions>
            </plugin>