简体   繁体   中英

Swagger and Play Framework - using binders

I have this problem in my team.

Using Play Framework, I have defined this route:

GET  /profiles/:profile/emails  @controllers.Emails.indexByProfileId(profile: Long, page: Int ?= 1, pagesize: Int ?= 25)

I use swagger to document the route:

def indexByProfileId(
    @ApiParam(value = "Profile id", required = true) @PathParam("profileId")
    profileId: Long,
    @ApiParam(value = "Page number", required = false) @PathParam("page")
    page: Int,
    @ApiParam(value = "Page size", required = false) @PathParam("pageSize")
    pageSize: Int) = ...

All works well. However, when I try to define a binder for page and pageSize , Swagger doesn't work any more. The binder works if I disable Swagger. This is the exception that is thrown:

Problem loading class:  controllers.Emails.indexByProfileId(profile:com.pure360.db.Id, page:dto.PaginationDTO ?= dto. java
.lang.ClassNotFoundException: class controllers.Emails.indexByProfileId(profile:com.pure360.db.Id, page:dto.PaginationDTO ?= dto not found

I'm supposing that Swagger is confused because the route defines a total of 3 parameters, but the endpoint now defines only 2 because of the binder. Is there a way of letting Swagger know about this?

Thanks

please open a ticket on swagger-core . The play framework support is being rewritten, and we can make sure this use case is well documented.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM