updated 1.2 tests

This commit is contained in:
Tony Tam 2013-08-11 09:42:53 -07:00
parent 5a064d6bad
commit 93067a0ce0
4 changed files with 17 additions and 16 deletions

View File

@ -302,8 +302,8 @@ object SwaggerSerializers {
case _ => false case _ => false
}, },
(json \ "allowMultiple").extractOrElse(false), (json \ "allowMultiple").extractOrElse(false),
(json \ "dataType").extractOrElse({ (json \ "type").extractOrElse({
!!(json, OPERATION_PARAM, "dataType", "missing required field", ERROR) !!(json, OPERATION_PARAM, "type", "missing required field", ERROR)
"" ""
}), }),
allowableValues, allowableValues,
@ -320,7 +320,7 @@ object SwaggerSerializers {
("defaultValue" -> x.defaultValue) ~ ("defaultValue" -> x.defaultValue) ~
("required" -> x.required) ~ ("required" -> x.required) ~
("allowMultiple" -> x.allowMultiple) ~ ("allowMultiple" -> x.allowMultiple) ~
("dataType" -> x.dataType) ~ ("type" -> x.dataType) ~
("allowableValues" -> { ("allowableValues" -> {
x.allowableValues match { x.allowableValues match {
case AnyAllowableValues => JNothing // don't serialize when not a concrete type case AnyAllowableValues => JNothing // don't serialize when not a concrete type

View File

@ -12,6 +12,7 @@
"apis": [ "apis": [
{ {
"path": "/pet/{petId}", "path": "/pet/{petId}",
"description":"Operations about pets",
"operations": [ "operations": [
{ {
"method": "GET", "method": "GET",

View File

@ -116,7 +116,7 @@ class ApiDescriptionValidationTest extends FlatSpec with ShouldMatchers {
"defaultValue":"-1", "defaultValue":"-1",
"required":false, "required":false,
"allowMultiple":true, "allowMultiple":true,
"dataType":"string", "type":"string",
"enum":["a","b","c"], "enum":["a","b","c"],
"paramType":"query" "paramType":"query"
} }
@ -154,7 +154,7 @@ class OperationValidationTest extends FlatSpec with ShouldMatchers {
"defaultValue":"-1", "defaultValue":"-1",
"required":false, "required":false,
"allowMultiple":true, "allowMultiple":true,
"dataType":"string", "type":"string",
"enum":["a","b","c"] "enum":["a","b","c"]
} }
] ]
@ -183,7 +183,7 @@ class OperationValidationTest extends FlatSpec with ShouldMatchers {
List.empty, List.empty,
List(Parameter("id", Some("the id"), Some("-1"), false, true, "string", AllowableListValues(List("a","b","c")), "query")) List(Parameter("id", Some("the id"), Some("-1"), false, true, "string", AllowableListValues(List("a","b","c")), "query"))
) )
write(op) should be ("""{"method":"get","summary":"the summary","notes":"the notes","responseClass":"string","nickname":"getMeSomeStrings","parameters":[{"name":"id","description":"the id","defaultValue":"-1","required":false,"allowMultiple":true,"dataType":"string","allowableValues":{"valueType":"LIST","values":["a","b","c"]},"paramType":"query"}]}""") write(op) should be ("""{"method":"get","summary":"the summary","notes":"the notes","responseClass":"string","nickname":"getMeSomeStrings","parameters":[{"name":"id","description":"the id","defaultValue":"-1","required":false,"allowMultiple":true,"type":"string","allowableValues":{"valueType":"LIST","values":["a","b","c"]},"paramType":"query"}]}""")
} }
} }
@ -232,7 +232,7 @@ class ParameterValidationTest extends FlatSpec with ShouldMatchers {
], ],
"valueType":"LIST" "valueType":"LIST"
}, },
"dataType":"string", "type":"string",
"allowMultiple":false, "allowMultiple":false,
"paramType":"query" "paramType":"query"
} }
@ -260,7 +260,7 @@ class ParameterValidationTest extends FlatSpec with ShouldMatchers {
"defaultValue":"tony", "defaultValue":"tony",
"required":false, "required":false,
"allowMultiple":true, "allowMultiple":true,
"dataType":"string", "type":"string",
"paramType":"query" "paramType":"query"
} }
""" """
@ -281,7 +281,7 @@ class ParameterValidationTest extends FlatSpec with ShouldMatchers {
it should "serialize a parameter" in { it should "serialize a parameter" in {
val l = Parameter("name", Some("description"), Some("tony"), false, true, "string", AnyAllowableValues, "query") val l = Parameter("name", Some("description"), Some("tony"), false, true, "string", AnyAllowableValues, "query")
write(l) should be ("""{"name":"name","description":"description","defaultValue":"tony","required":false,"allowMultiple":true,"dataType":"string","paramType":"query"}""") write(l) should be ("""{"name":"name","description":"description","defaultValue":"tony","required":false,"allowMultiple":true,"type":"string","paramType":"query"}""")
} }
} }

View File

@ -147,7 +147,7 @@ class ApiDescriptionSerializersTest extends FlatSpec with ShouldMatchers {
"defaultValue":"-1", "defaultValue":"-1",
"required":false, "required":false,
"allowMultiple":true, "allowMultiple":true,
"dataType":"string", "type":"string",
"enum":["a","b","c"], "enum":["a","b","c"],
"paramType":"query" "paramType":"query"
} }
@ -203,7 +203,7 @@ class ApiDescriptionSerializersTest extends FlatSpec with ShouldMatchers {
List(Parameter("id", Some("the id"), Some("-1"), false, true, "string", AllowableListValues(List("a","b","c")), "query")) List(Parameter("id", Some("the id"), Some("-1"), false, true, "string", AllowableListValues(List("a","b","c")), "query"))
)) ))
) )
write(l) should be ("""{"path":"/foo/bar","description":"the description","operations":[{"method":"get","summary":"the summary","notes":"the notes","responseClass":"string","nickname":"getMeSomeStrings","parameters":[{"name":"id","description":"the id","defaultValue":"-1","required":false,"allowMultiple":true,"dataType":"string","allowableValues":{"valueType":"LIST","values":["a","b","c"]},"paramType":"query"}]}]}""") write(l) should be ("""{"path":"/foo/bar","description":"the description","operations":[{"method":"get","summary":"the summary","notes":"the notes","responseClass":"string","nickname":"getMeSomeStrings","parameters":[{"name":"id","description":"the id","defaultValue":"-1","required":false,"allowMultiple":true,"type":"string","allowableValues":{"valueType":"LIST","values":["a","b","c"]},"paramType":"query"}]}]}""")
} }
} }
@ -226,7 +226,7 @@ class OperationSerializersTest extends FlatSpec with ShouldMatchers {
"defaultValue":"-1", "defaultValue":"-1",
"required":false, "required":false,
"allowMultiple":true, "allowMultiple":true,
"dataType":"string", "type":"string",
"enum":["a","b","c"], "enum":["a","b","c"],
"paramType":"query" "paramType":"query"
} }
@ -271,7 +271,7 @@ class OperationSerializersTest extends FlatSpec with ShouldMatchers {
List.empty, List.empty,
List(Parameter("id", Some("the id"), Some("-1"), false, true, "string", AllowableListValues(List("a","b","c")), "query")) List(Parameter("id", Some("the id"), Some("-1"), false, true, "string", AllowableListValues(List("a","b","c")), "query"))
) )
write(op) should be ("""{"method":"get","summary":"the summary","notes":"the notes","responseClass":"string","nickname":"getMeSomeStrings","parameters":[{"name":"id","description":"the id","defaultValue":"-1","required":false,"allowMultiple":true,"dataType":"string","allowableValues":{"valueType":"LIST","values":["a","b","c"]},"paramType":"query"}]}""") write(op) should be ("""{"method":"get","summary":"the summary","notes":"the notes","responseClass":"string","nickname":"getMeSomeStrings","parameters":[{"name":"id","description":"the id","defaultValue":"-1","required":false,"allowMultiple":true,"type":"string","allowableValues":{"valueType":"LIST","values":["a","b","c"]},"paramType":"query"}]}""")
} }
} }
@ -317,7 +317,7 @@ class ParameterSerializersTest extends FlatSpec with ShouldMatchers {
false, false,
true true
], ],
"dataType":"string", "type":"string",
"allowMultiple":false, "allowMultiple":false,
"paramType":"query" "paramType":"query"
} }
@ -345,7 +345,7 @@ class ParameterSerializersTest extends FlatSpec with ShouldMatchers {
"defaultValue":"tony", "defaultValue":"tony",
"required":false, "required":false,
"allowMultiple":true, "allowMultiple":true,
"dataType":"string", "type":"string",
"paramType":"query" "paramType":"query"
} }
""" """
@ -366,7 +366,7 @@ class ParameterSerializersTest extends FlatSpec with ShouldMatchers {
it should "serialize a parameter" in { it should "serialize a parameter" in {
val l = Parameter("name", Some("description"), Some("tony"), false, true, "string", AnyAllowableValues, "query") val l = Parameter("name", Some("description"), Some("tony"), false, true, "string", AnyAllowableValues, "query")
write(l) should be ("""{"name":"name","description":"description","defaultValue":"tony","required":false,"allowMultiple":true,"dataType":"string","paramType":"query"}""") write(l) should be ("""{"name":"name","description":"description","defaultValue":"tony","required":false,"allowMultiple":true,"type":"string","paramType":"query"}""")
} }
} }