我试图在我的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的示例项目,我看不出有什么特别的东西让它起作用.
我正在尝试使用JDBC和PostgreSQL进行查询,但我遇到了一个奇怪的情况,我在任何文档中都找不到.
如果我通过pgAdmin和H2(我用于我的应用程序的单元测试)执行它,以下查询有效,但如果我通过JDBC执行它,我会收到语法错误:
Queries.SELECT_SQL
SELECT columns
FROM Table
LEFT JOIN TableToJoin1
LEFT JOIN TableToJoin2
LEFT JOIN TableToJoin3
JOIN TableToJoin4
Run Code Online (Sandbox Code Playgroud)
Queries.ENDING_PAGING_STATEMENT_SQL
OFFSET ? ROWS FETCH FIRST ? ROWS ONLY
Run Code Online (Sandbox Code Playgroud)
该SELECT查询是正确的,使用任何手段工作正常,问题是当我拿到这两个查询一起,即SELECT沿语句OFFSET和FETCH FIRST.
这就是我通过JDBC以下方式执行查询的方式:
// Receive offset and limit as argument.
try (final PreparedStatement selectStatement = connection
.prepareStatement(Queries.SELECT_SQL + Queries.ENDING_PAGING_STATEMENT_SQL)) {
selectStatement.setInt(Queries.PAGING_ENDING_STATEMENT_OFFSET_ARGUMENT_POSITION, offset);
selectStatement.setInt(Queries.PAGING_ENDING_STATEMENT_LIMIT_ARGUMENT_POSITION, limit);
final ResultSet resultSet = bookSelectStatement.executeQuery();
...
}
Run Code Online (Sandbox Code Playgroud)
以下是抛出异常的消息:
org.postgresql.util.PSQLException: ERROR: syntax error at or near "$2"
Run Code Online (Sandbox Code Playgroud)
如果我打电话selectStatement.toString()给调试,我会完全按照我的预期收到查询. …