From 93067a0ce0ee08a6a84163e330397576bad283ce Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sun, 11 Aug 2013 09:42:53 -0700 Subject: [PATCH] updated 1.2 tests --- .../swagger/model/SwaggerModelSerializer.scala | 6 +++--- src/test/resources/petstore-1.2/pet | 1 + .../ModelSerializerValidations.scala | 12 ++++++------ .../swaggerSpec1_2/ModelSerializersTest.scala | 14 +++++++------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/main/scala/com/wordnik/swagger/model/SwaggerModelSerializer.scala b/src/main/scala/com/wordnik/swagger/model/SwaggerModelSerializer.scala index 1fb5c303404..be6630a9f67 100644 --- a/src/main/scala/com/wordnik/swagger/model/SwaggerModelSerializer.scala +++ b/src/main/scala/com/wordnik/swagger/model/SwaggerModelSerializer.scala @@ -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 diff --git a/src/test/resources/petstore-1.2/pet b/src/test/resources/petstore-1.2/pet index 2522ae0e6ff..a36d679818d 100644 --- a/src/test/resources/petstore-1.2/pet +++ b/src/test/resources/petstore-1.2/pet @@ -12,6 +12,7 @@ "apis": [ { "path": "/pet/{petId}", + "description":"Operations about pets", "operations": [ { "method": "GET", diff --git a/src/test/scala/swaggerSpec1_2/ModelSerializerValidations.scala b/src/test/scala/swaggerSpec1_2/ModelSerializerValidations.scala index 708e6fd330a..76989787a9b 100644 --- a/src/test/scala/swaggerSpec1_2/ModelSerializerValidations.scala +++ b/src/test/scala/swaggerSpec1_2/ModelSerializerValidations.scala @@ -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"}""") } } diff --git a/src/test/scala/swaggerSpec1_2/ModelSerializersTest.scala b/src/test/scala/swaggerSpec1_2/ModelSerializersTest.scala index 50e4d6b9a76..ad0851ebf55 100644 --- a/src/test/scala/swaggerSpec1_2/ModelSerializersTest.scala +++ b/src/test/scala/swaggerSpec1_2/ModelSerializersTest.scala @@ -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"}""") } }