Kongchen Swagger忽略了@ApiModelProperty注释

Mag*_*nto 7 java annotations swagger

我试图在我的Swagger文档中添加更多信息,但是我@ApiPropertyModel在具体的注释中遇到了一些问题.

我尝试做什么并不重要,它只是不起作用.该插件生成Swagger.json正确,所有的@ApiOperation注释工作的REST资源,但对于模型的一部分,它只是内省模型类的属性,不看他们上面的注释.

以下是插件的配置方式:

<plugin>
    <groupId>com.github.kongchen</groupId>
    <artifactId>swagger-maven-plugin</artifactId>
    <version>3.1.5</version>

    <configuration>
        <apiSources>
            <apiSource>
                <locations>
                    <location>com.example.rest.resources</location>
                    <location>com.example.rest.model</location>
                </locations>
                <swaggerDirectory>${project.build.directory}/generated-sources</swaggerDirectory>
                <basePath>/path/to/the/api</basePath>
                <info>
                    <title>My RESTful API Documentation</title>
                    <version>${project.version}</version>
                </info>
            </apiSource>
        </apiSources>
    </configuration>

    <executions>
        <execution>
            <phase>generate-sources</phase>
            <goals>
                <goal>generate</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

如果我有例如:

@ApiModelProperty(example = "test example")
public String test;
Run Code Online (Sandbox Code Playgroud)

它将生成test属性,但不会创建我在该批注中设置的任何示例或任何其他属性.在吸气剂中使用它时会发生同样的情况,所以我认为这不是问题所在.

我做错了吗?另外,我看了Kongchen的示例项目,我看不出有什么特别的东西让它起作用.

tkr*_*use 0

也许您忘记了@ApiModel模型类上的注释?

喜欢:

@ApiModel
public class PostRequest {

    @ApiModelProperty(example = "test example")
    public String test;

}
Run Code Online (Sandbox Code Playgroud)

或者您的模型包与 pom.xml 中给出的内容不匹配。