Skip to content

Commit 73c5d4c

Browse files
committed
updated tests, models for swagger-api/swagger-codegen#501
1 parent e13e549 commit 73c5d4c

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

modules/swagger-core/src/test/scala/ModelConverterTest.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ class ModelConverterTest extends FlatSpec with Matchers {
7878
},
7979
"isDomestic" : {
8080
"type" : "boolean",
81-
"position" : 3
81+
"position" : 3,
82+
"default" : false
8283
}
8384
}
8485
}
@@ -108,7 +109,8 @@ class ModelConverterTest extends FlatSpec with Matchers {
108109
},
109110
"isDomestic" : {
110111
"type" : "boolean",
111-
"position" : 3
112+
"position" : 3,
113+
"default": false
112114
}
113115
}
114116
}

modules/swagger-core/src/test/scala/ScalaModelTest.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ class ScalaModelTest extends FlatSpec with Matchers {
9696
"format" : "date-time"
9797
},
9898
"booleanValue" : {
99-
"type" : "boolean"
99+
"type" : "boolean",
100+
"default": false
100101
}
101102
}
102103
}
@@ -151,6 +152,7 @@ class ScalaModelTest extends FlatSpec with Matchers {
151152
},
152153
"isDomestic" : {
153154
"type" : "boolean",
155+
"default": false,
154156
"position" : 3
155157
}
156158
}

modules/swagger-core/src/test/scala/properties/PropertySerializationTest.scala

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ class PropertySerializationTest extends FlatSpec with Matchers {
1515

1616
it should "serialize a BooleanProperty" in {
1717
val p = new BooleanProperty()
18-
m.writeValueAsString(p) should be ("""{"type":"boolean"}""")
18+
._default(true)
19+
20+
m.writeValueAsString(p) should be ("""{"type":"boolean","default":true}""")
1921
}
2022

2123
it should "deserialize a BooleanProperty" in {
22-
val json = """{"type":"boolean"}"""
24+
val json = """{"type":"boolean","default":false}"""
2325
val p = m.readValue(json, classOf[Property])
2426
p.getType should be ("boolean")
2527
p.getFormat should be (null)
2628
p.getClass should be (classOf[BooleanProperty])
29+
p.asInstanceOf[BooleanProperty].getDefault should equal (false)
2730
m.writeValueAsString(p) should equal (json)
2831
}
2932

@@ -57,7 +60,8 @@ class PropertySerializationTest extends FlatSpec with Matchers {
5760

5861
it should "serialize a DoubleProperty" in {
5962
val p = new DoubleProperty()
60-
m.writeValueAsString(p) should be ("""{"type":"number","format":"double"}""")
63+
._default(3.14159)
64+
m.writeValueAsString(p) should be ("""{"type":"number","format":"double","default":3.14159}""")
6165
}
6266

6367
it should "deserialize a DoubleProperty" in {
@@ -71,7 +75,8 @@ class PropertySerializationTest extends FlatSpec with Matchers {
7175

7276
it should "serialize a FloatProperty" in {
7377
val p = new FloatProperty()
74-
m.writeValueAsString(p) should be ("""{"type":"number","format":"float"}""")
78+
._default(1.2f)
79+
m.writeValueAsString(p) should be ("""{"type":"number","format":"float","default":1.2}""")
7580
}
7681

7782
it should "deserialize a FloatProperty" in {
@@ -85,7 +90,8 @@ class PropertySerializationTest extends FlatSpec with Matchers {
8590

8691
it should "serialize an IntegerProperty" in {
8792
val p = new IntegerProperty()
88-
m.writeValueAsString(p) should be ("""{"type":"integer","format":"int32"}""")
93+
._default(32)
94+
m.writeValueAsString(p) should be ("""{"type":"integer","format":"int32","default":32}""")
8995
}
9096

9197
it should "deserialize a IntegerProperty" in {
@@ -99,7 +105,8 @@ class PropertySerializationTest extends FlatSpec with Matchers {
99105

100106
it should "serialize a LongProperty" in {
101107
val p = new LongProperty()
102-
m.writeValueAsString(p) should be ("""{"type":"integer","format":"int64"}""")
108+
._default(8675309L)
109+
m.writeValueAsString(p) should be ("""{"type":"integer","format":"int64","default":8675309}""")
103110
}
104111

105112
it should "deserialize a LongProperty" in {
@@ -164,7 +171,8 @@ class PropertySerializationTest extends FlatSpec with Matchers {
164171

165172
it should "serialize a StringProperty" in {
166173
val p = new StringProperty()
167-
m.writeValueAsString(p) should be ("""{"type":"string"}""")
174+
._default("Bob")
175+
m.writeValueAsString(p) should be ("""{"type":"string","default":"Bob"}""")
168176
}
169177

170178
it should "deserialize a StringProperty" in {

0 commit comments

Comments
 (0)