swagger-api / swagger-play

Apache License 2.0
330 stars 181 forks source link

Play Framework binders #3

Open webron opened 8 years ago

webron commented 8 years ago

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 commented 8 years ago

From @fehguy on April 2, 2015 4:20

Will look into this for m3.

webron commented 8 years ago

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.