如何使用maven-swagger-codegen-plugin生成文档?

时间:2016-07-18 04:40:44

标签: java maven swagger-2.0 swagger-codegen

我已经配置了像这样的swagger-codegen-plugin

    @Inject
    private Provider<EntityManager> em;

    @GET
    @Transactional
    @Path("/reset")
    public void resetData() {

        logger.info("Processing reset");
        try {

            em.get().getTransaction().begin();

            for (int i = 0; i < 10; i++) {
                em.get().persist(new Product("Product_" + i, "Desc_" + i));
            }
            em.get().flush();
            em.get().getTransaction().commit();

        } catch (Exception e) {
            throw new WebApplicationException(Response.Status.FORBIDDEN);
        }
    }

一切正常,但当我将语言更改为 <plugin> <groupId>io.swagger</groupId> <artifactId>swagger-codegen-maven-plugin</artifactId> <version>2.1.5</version> <executions> <execution> <goals> <goal>generate</goal> </goals> <configuration> <inputSpec>${project.basedir}/src/main/resources/model.json</inputSpec> <language>java</language> <configOptions> <sourceFolder>src/gen/java/main</sourceFolder> </configOptions> <modelPackage>com.mypackage</modelPackage> <environmentVariables> <models></models> <supportingFiles>false</supportingFiles> </environmentVariables> </configuration> </execution> </executions> </plugin> 时,没有任何内容生成。

那么如何生成staitc html文档?

1 个答案:

答案 0 :(得分:0)

目前,您正在将语言指定为<language>java</language>来生成html,这应该是<language>html</language><language>html2</language>,因为这会指定swagger-codegen的输出语言生成器。

有2种不同的html生成器,因此您需要确定自己喜欢的口味。

相关问题