Skip to content

Commit c5aa988

Browse files
committed
tests for #943
1 parent 0a0745c commit c5aa988

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

modules/swagger-jaxrs/src/test/scala/SubResourceScannerTest.scala

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import resources._
22

3+
import models._
4+
35
import com.wordnik.swagger.jaxrs.config._
46
import com.wordnik.swagger.models.parameters._
57
import com.wordnik.swagger.models.properties.MapProperty
@@ -18,8 +20,13 @@ import org.scalatest.Matchers
1820
@RunWith(classOf[JUnitRunner])
1921
class SubResourceScannerTest extends FlatSpec with Matchers {
2022
it should "scan a resource with subresources" in {
21-
// val swagger = new Reader(new Swagger()).read(classOf[ResourceWithSubResources])
22-
// Json.prettyPrint(swagger)
23+
val swagger = new Reader(new Swagger()).read(classOf[ResourceWithSubResources])
24+
25+
val employees = swagger.getPaths().get("/employees").getGet
26+
employees.getOperationId() should be ("getTest")
27+
28+
val employeesId = swagger.getPaths().get("/employees/{id}").getGet
29+
employeesId.getOperationId() should be ("getSubresourceOperation")
2330
}
2431

2532
it should "scan another resource with subresources" in {
@@ -36,4 +43,12 @@ class SubResourceScannerTest extends FlatSpec with Matchers {
3643

3744
swagger.getPaths().keySet().size() should be (2)
3845
}
39-
}
46+
47+
it should "find a body param" in {
48+
val swagger = new Reader(new Swagger()).read(classOf[Resource942])
49+
val post = swagger.getPaths().get("/test").getPost
50+
val param = post.getParameters().get(0).asInstanceOf[BodyParameter];
51+
52+
param.getSchema should not be (null)
53+
}
54+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package resources;
2+
3+
import models.Employee;
4+
import com.wordnik.swagger.annotations.*;
5+
6+
import javax.ws.rs.*;
7+
import javax.ws.rs.core.Response;
8+
9+
import java.util.*;
10+
11+
@Api("/test")
12+
@Path("/test")
13+
public class Resource942 {
14+
@ApiOperation(value="test")
15+
@POST
16+
public void addTest(Employee employee) {
17+
return;
18+
}
19+
}

0 commit comments

Comments
 (0)