-
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.
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
modules/swagger-core/src/test/scala/converter/PropertyAnnotationTest.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,45 @@ | ||
package converter | ||
|
||
import converter.models._ | ||
|
||
import com.wordnik.swagger.converter._ | ||
import com.wordnik.swagger.model._ | ||
|
||
import com.wordnik.swagger.annotations._ | ||
import com.wordnik.swagger.converter._ | ||
import com.wordnik.swagger.core.util._ | ||
import com.wordnik.swagger.model._ | ||
|
||
import scala.reflect.BeanProperty | ||
import scala.collection.mutable.LinkedHashMap | ||
|
||
import org.junit.runner.RunWith | ||
import org.scalatest.junit.JUnitRunner | ||
import org.scalatest.FlatSpec | ||
import org.scalatest.matchers.ShouldMatchers | ||
|
||
import javax.xml.bind.annotation._ | ||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class PropertyAnnotationTest extends FlatSpec with ShouldMatchers { | ||
it should "read annotations on a property" in { | ||
val a = ModelConverters.readAll(classOf[ModelWithAnnotationOnProperty]) | ||
JsonSerializer.asJson(a) should be ("""[{"id":"ModelWithAnnotationOnProperty","description":"my annotated model","properties":{"count":{"type":"integer","format":"int32","description":"the count of items"}}}]""") | ||
|
||
/* | ||
[ | ||
{ | ||
"id": "ModelWithAnnotationOnProperty", | ||
"description": "my annotated model", | ||
"properties": { | ||
"count": { | ||
"type": "integer", | ||
"format": "int32", | ||
"description": "the count of items" | ||
} | ||
} | ||
} | ||
] | ||
*/ | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
modules/swagger-core/src/test/scala/converter/models/ModelWithAnnotationOnProperty.java
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,17 @@ | ||
package converter.models; | ||
|
||
import com.wordnik.swagger.annotations.*; | ||
|
||
@ApiModel(description = "my annotated model") | ||
public class ModelWithAnnotationOnProperty { | ||
@ApiModelProperty(value = "the count of items", position = 1) | ||
private Integer count; | ||
|
||
public void setCount(Integer count) { | ||
this.count = count; | ||
} | ||
|
||
public Integer getCount() { | ||
return count; | ||
} | ||
} |