1

我正在使用 swagger-maven-plugin 3.1.7 如下:

<plugin>
        <groupId>com.github.kongchen</groupId>
        <artifactId>swagger-maven-plugin</artifactId>
        <version>3.1.7</version>
        <configuration>
          <apiSources>
            <apiSource>
              <springmvc>true</springmvc>
              <locations>"path to controller"</locations>
              <info>
                <title>"title"</title>
                <version>v1</version>
              </info>
              <outputPath>${project.build.directory}/swagger/client_api.json</outputPath>
              <swaggerDirectory>${project.build.directory}/swagger</swaggerDirectory>
            </apiSource>
          </apiSources>
        </configuration>
        <executions>
          <execution>
            <phase>test</phase>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

我添加了以下招摇依赖项

    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger2</artifactId>
      <version>2.9.2</version>
    </dependency>

    <dependency>
      <groupId>io.springfox</groupId>
      <artifactId>springfox-swagger-ui</artifactId>
      <version>2.9.2</version>
    </dependency>

我的控制器带有注释

@RequestMapping at class level and at method level.
@Api at the class level
@ApiOperation at the method level

但我仍然得到一个空的 swagger.json 文件。

这是多模块项目的一部分,其中出现错误。在非多模块项目中添加相同的依赖项和流程完全可以生成 swagger.json。

如果我做错了什么,有人可以告诉我吗?

4

0 回答 0