使用swagger-maven-plugin时缺少swagger.json输出

时间:2018-07-26 23:45:52

标签: java maven swagger

我试图根据源代码中的注释自动生成一个swagger.json文件,该文件描述了我的软件公开的api。

设置为:

  • Java
  • Jax-RS
  • 要部署到Wildfly(尽管我认为这并不重要)
  • Maven swagger-maven-plugin

我已按照以下说明进行操作: https://github.com/kongchen/swagger-maven-plugin

,示例位于: https://github.com/swagger-maven-plugin/swagger-maven-example

我的POM包含:

        <plugin>
            <groupId>com.github.kongchen</groupId>
            <artifactId>swagger-maven-plugin</artifactId>
            <version>3.1.1</version>
            <configuration>
                <apiSources>
                    <apiSource>
                        <springmvc>false</springmvc>
                        <locations>
                            <location>com.paconsulting.rice.serviceregister.restendpoints</location>
                        </locations>
                        <schemes>
                            <scheme>http</scheme>
                            <scheme>https</scheme>
                        </schemes>
                        <host>www.xxxserviceregister.com:8080</host>
                        <basePath>/api</basePath>
                        <info>
                        <title>Swagger Maven Plugin Sample</title>
                        <version>v1</version>
                        <description>This is a sample for swagger-maven-plugin</description>
                        <termsOfService>
                            http://www.github.com/kongchen/swagger-maven-plugin
                        </termsOfService>
                        <contact>
                            <email>kongchen@gmail.com</email>
                            <name>Kong Chen</name>
                            <url>http://kongch.com</url>
                        </contact>
                        <license>
                            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
                            <name>Apache 2.0</name>
                        </license>
                    </info>

                        <swaggerDirectory>generated/swagger-ui</swaggerDirectory>
                        <swaggerFileName>swagger.json</swaggerFileName>
                        <attachSwaggerArtifact>true</attachSwaggerArtifact>
                    </apiSource>
                </apiSources>
            </configuration>

            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>

        </plugin>

我的其中一个课程的示例是:

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;


// The Java class will be hosted at the URI path "/catalogue"
@Path("/catalogue")
@Api(value = "/api", description = "Operations about catalogues")
public class RESTCatalogue {
    private static final Logger Log = LoggerFactory.getLogger(RESTLibrary.class);

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public ArrayList<Catalogue> RESTgetCatalogues() {
        Log.debug("A consumer called the /api/catalogue end point which calls the getCatalogueRESTHandler Class");

        return com.me.serviceregister.resthandlers.RESTCatalogueHandler.getCataloguesRESTHandler();
    }

当我跑步时:

mvn compile

mvn clean install

我希望将一个名为swagger.json的文件放置在generate / swagger-ui中,但是我什么也没得到。

用于mvn编译的mvn输出为:

[INFO] Scanning for projects...
[WARNING] 
[WARNING] Some problems were encountered while building the effective model for com.PAConsulting.RICE:service-register:war:2.0
[WARNING] 'build.pluginManagement.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.wildfly.plugins:wildfly-maven-plugin @ line 103, column 13
[WARNING] 
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING] 
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING] 
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building service-register 2.0
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ service-register ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ service-register ---
[INFO] Nothing to compile - all classes are up to date
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.525 s
[INFO] Finished at: 2018-07-27T00:40:57+01:00
[INFO] Final Memory: 9M/232M
[INFO] ------------------------------------------------------------------------

我明显做错了什么吗?

非常感谢

0 个答案:

没有答案