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

View File

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

View File

@ -116,7 +116,7 @@ class ApiDescriptionValidationTest extends FlatSpec with ShouldMatchers {
"defaultValue":"-1",
"required":false,
"allowMultiple":true,
"dataType":"string",
"type":"string",
"enum":["a","b","c"],
"paramType":"query"
}
@ -154,7 +154,7 @@ class OperationValidationTest extends FlatSpec with ShouldMatchers {
"defaultValue":"-1",
"required":false,
"allowMultiple":true,
"dataType":"string",
"type":"string",
"enum":["a","b","c"]
}
]
@ -183,7 +183,7 @@ class OperationValidationTest extends FlatSpec with ShouldMatchers {
List.empty,
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"
},
"dataType":"string",
"type":"string",
"allowMultiple":false,
"paramType":"query"
}
@ -260,7 +260,7 @@ class ParameterValidationTest extends FlatSpec with ShouldMatchers {
"defaultValue":"tony",
"required":false,
"allowMultiple":true,
"dataType":"string",
"type":"string",
"paramType":"query"
}
"""
@ -281,7 +281,7 @@ class ParameterValidationTest extends FlatSpec with ShouldMatchers {
it should "serialize a parameter" in {
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",
"required":false,
"allowMultiple":true,
"dataType":"string",
"type":"string",
"enum":["a","b","c"],
"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"))
))
)
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",
"required":false,
"allowMultiple":true,
"dataType":"string",
"type":"string",
"enum":["a","b","c"],
"paramType":"query"
}
@ -271,7 +271,7 @@ class OperationSerializersTest extends FlatSpec with ShouldMatchers {
List.empty,
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,
true
],
"dataType":"string",
"type":"string",
"allowMultiple":false,
"paramType":"query"
}
@ -345,7 +345,7 @@ class ParameterSerializersTest extends FlatSpec with ShouldMatchers {
"defaultValue":"tony",
"required":false,
"allowMultiple":true,
"dataType":"string",
"type":"string",
"paramType":"query"
}
"""
@ -366,7 +366,7 @@ class ParameterSerializersTest extends FlatSpec with ShouldMatchers {
it should "serialize a parameter" in {
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"}""")
}
}