java - 个性化路线格式 - Swagger with Play Framework

标签 java playframework routes swagger

我正在使用 Play Framework 开发带有 Swagger UI 的 API。

但是我遇到了一个小问题(不是大问题): 我的网址是:

https://url/find?param1=false&&&param4=1

但是当未给出参数时我有“&&”(我的意思是param2和param3) 我想要的很简单:

https://url/find?param1=false&param4=1

这里是: 我的 Controller :

@Api(value = "url", description = "...")
public class nameClassApiController extends ApiController {

@ApiOperation(value = "...", notes = "...", response = nameClass.class, httpMethod = "GET")
@ApiResponses(value = { @ApiResponse(code = 200, message = "success"), @ApiResponse(code = 500, message = "error", response = ApiError.class) })


public static Result getList(
@ApiParam(value = "param1", required = false) @QueryParam("param1") Long param1,
@ApiParam(value = "param2", required = false) @QueryParam("param2") Long param2, ....) {

return getJsonSuccessResponse(className.getList(param1, param2, ...));

}

还有我的路线定义:

GET  url/find  className.getList(param1: java.lang.Long ?= null, param2: java.lang.Long ?= null, param3: java.lang.Long ?= null, param4: java.lang.Long ?= null)

注意:Te 参数是可选的,因此在我的 route 我需要将参数默认设置为 null。

有什么解决办法吗? 谢谢!

最佳答案

通过将 swagger-UI 版本升级到 2.0(最新)修复

关于java - 个性化路线格式 - Swagger with Play Framework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29923131/

相关文章:

java - 如何强制 Play 2.1 针对其他 Java 版本进行编译

java - 如何在 Spring MVC 中正确使用多个 Controller

ruby-on-rails - `add_route' : Invalid route name, 已在使用中:'new_user_session' (ArgumentError)

java - 连接四的极小极大

java - 杂交 : How to import media which is in the zip file in impex?

java - 无论如何告诉编译器通过注释保留变量名?

java - 无法进入我的 spring boot Controller 方法

java - 违反完整性约束

scala - Play Framework : How to modify the response body without blocking?

typescript - React Navigation V5 + Typescript 错误 : Property 'fullName' does not exist on type 'object'