【问题标题】:using swagger-codegen-maven-plugin without spring-boot dependency使用没有 spring-boot 依赖的 swagger-codegen-maven-plugin
【发布时间】:2017-07-21 14:01:18
【问题描述】:

我需要使用 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 依赖的情况下使用这个插件?

【问题讨论】:

    标签: swagger swagger-codegen


    【解决方案1】:
      <!-- 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>
    

    【讨论】:

    • 虽然此代码可能会回答问题,但提供有关它如何和/或为什么解决问题的额外上下文将提高​​答案的长期价值。
    猜你喜欢
    • 1970-01-01
    • 2017-11-10
    • 2021-06-27
    • 1970-01-01
    • 2018-02-11
    • 1970-01-01
    • 2022-10-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多