Skip to content

Commit

Permalink
merged in master
Browse files Browse the repository at this point in the history
  • Loading branch information
kailuowang committed May 9, 2016
2 parents 3fb2b7e + f365fa7 commit 85641d0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ val spec: Try[JsObject] = ps.generate().map(_ + ("host" -> JsString(myHost)))
SwaggerSpecGenerator(domainPackage).generate("myRoutes.routes")
```

#### How to find more examples?
In the tests!
/test/scala/com.iheart.playSwagger/SwaggerSpecGeneratorSpec.scala
#### Where to find more examples?
In the [tests](/src/test/scala/com/iheart/playSwagger/SwaggerSpecGeneratorSpec.scala)!



Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object SwaggerParameterMapper {
SwaggerParameter(parameter.name, referenceType = Some(referenceType))

def optionalParam(optionalTpe: String) = {
val param = if (isReference(optionalTpe)) referenceParam(optionalTpe) else mapParam(parameter.copy(typeName = optionalTpe))
val param = if (isReference(optionalTpe)) referenceParam(optionalTpe) else mapParam(parameter.copy(typeName = optionalTpe), modelQualifier = modelQualifier)
param.copy(required = false, default = defaultValueO)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.iheart.playSwagger
import com.iheart.playSwagger.Domain.{Definition, SwaggerParameter}
import org.specs2.mutable.Specification

case class Foo(barStr: String, barInt: Int, barLong: Option[Long], reffedFoo: ReffedFoo)
case class Foo(barStr: String, barInt: Int, barLong: Option[Long], reffedFoo: ReffedFoo, seqReffedFoo: Seq[ReffedFoo], optionSeqReffedFoo: Option[Seq[ReffedFoo]])
case class ReffedFoo(name: String, refrefFoo: RefReffedFoo)
case class RefReffedFoo(bar: String)

Expand Down Expand Up @@ -44,7 +44,7 @@ class DefinitionGeneratorSpec extends Specification {

val result = DefinitionGenerator("com.iheart.playSwagger").definition[Foo].properties

result.length === 4
result.length === 6

"with correct string property" >> {
result.head === SwaggerParameter(name = "barStr", `type` = Some("string"))
Expand All @@ -62,6 +62,16 @@ class DefinitionGeneratorSpec extends Specification {
result(3) === SwaggerParameter(name = "reffedFoo", referenceType = Some("com.iheart.playSwagger.ReffedFoo"))
}

"with sequence of reference type" >> {
val itemsParam = SwaggerParameter(name = "seqReffedFoo", referenceType = Some("com.iheart.playSwagger.ReffedFoo"))
result(4) === SwaggerParameter(name = "seqReffedFoo", `type` = Some("array"), items = Some(itemsParam))
}

"with optional sequence of reference type" >> {
val itemsParam = SwaggerParameter(name = "optionSeqReffedFoo", referenceType = Some("com.iheart.playSwagger.ReffedFoo"))
result(5) === SwaggerParameter(name = "optionSeqReffedFoo", `type` = Some("array"), items = Some(itemsParam), required = false)
}

}

"read class in Object" >> {
Expand Down

0 comments on commit 85641d0

Please sign in to comment.