swagger-play icon indicating copy to clipboard operation
swagger-play copied to clipboard

Play Framework binders

Open webron opened this issue 10 years ago • 2 comments

From @sebigavril on April 1, 2015 13:14

*Swagger does not work with custom binders defined in Play Framework. Please add support for documenting binders. *

For example... 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.

cc @fehguy

Copied from original issue: swagger-api/swagger-core#956

webron avatar Aug 10 '15 22:08 webron

From @fehguy on April 2, 2015 4:20

Will look into this for m3.

webron avatar Aug 10 '15 22:08 webron

Sorry for the delayed response. Since we're not going to deal with it in 1.3, I've made reference to it from #918 so we can look into it in the new module.

webron avatar Aug 10 '15 22:08 webron