-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #537 from junbo/develop
Add @BeanParam support for Jersey2.
- Loading branch information
Showing
13 changed files
with
137 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
modules/swagger-jersey2-jaxrs/src/test/scala/BeanParamTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import com.wordnik.swagger.jersey.JerseyApiReader | ||
import testresources._ | ||
|
||
import com.wordnik.swagger.jaxrs.reader._ | ||
import com.wordnik.swagger.model._ | ||
import com.wordnik.swagger.config._ | ||
|
||
import org.junit.runner.RunWith | ||
import org.scalatest.junit.JUnitRunner | ||
import org.scalatest.FlatSpec | ||
import org.scalatest.matchers.ShouldMatchers | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class BeanParamTest extends FlatSpec with ShouldMatchers { | ||
it should "read beanparam parameters" in { | ||
val reader = new JerseyApiReader | ||
val config = new SwaggerConfig() | ||
val apiResource = reader.read("/api-docs", classOf[BeanParamResource], config).getOrElse(fail("should not be None")) | ||
|
||
val apis = apiResource.apis | ||
apis.size should be (1) | ||
|
||
val ops = apis.head.operations | ||
ops.size should be (1) | ||
|
||
val op = ops.head | ||
op.parameters.size should be (3) | ||
|
||
val param0 = op.parameters(0) | ||
param0.name should be ("ids") | ||
param0.dataType should be ("Set[string]") | ||
param0.paramType should be ("query") | ||
|
||
val param1 = op.parameters(1) | ||
param1.name should be ("startDate") | ||
param1.dataType should be ("Date") | ||
param1.paramType should be ("query") | ||
|
||
val param2 = op.parameters(2) | ||
param2.name should be ("name") | ||
param2.dataType should be ("string") | ||
param2.paramType should be ("query") | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
modules/swagger-jersey2-jaxrs/src/test/scala/testmodels/BeanParamModel.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package testmodels | ||
|
||
import com.wordnik.swagger.annotations.ApiParam | ||
import javax.ws.rs.QueryParam | ||
import java.util.Date | ||
|
||
class BeanParamModel { | ||
@ApiParam(value = "sample set param") | ||
@QueryParam("ids") | ||
var ids: Set[String] = _ | ||
|
||
@ApiParam(value = "sample date param") | ||
@QueryParam("startDate") | ||
var startDate: Date = _ | ||
|
||
@ApiParam(value = "sample string param") | ||
@QueryParam("name") | ||
var name: String = _ | ||
} |
16 changes: 16 additions & 0 deletions
16
modules/swagger-jersey2-jaxrs/src/test/scala/testresources/BeanParamResource.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package testresources | ||
|
||
import javax.ws.rs._ | ||
import com.wordnik.swagger.annotations._ | ||
import testmodels._ | ||
import javax.ws.rs.core.Response | ||
|
||
@Path("/beanParam") | ||
@Api(value = "/beanParam", description = "Bean Param Resource") | ||
class BeanParamResource { | ||
@GET | ||
@ApiOperation(value = "Search Object", notes = "No details provided", position = 0) | ||
def searchObject(@BeanParam params: BeanParamModel) { | ||
Response.ok.entity("ok").build | ||
} | ||
} |