@@ -31,16 +31,12 @@ class ResourceListingSerializersTest extends FlatSpec with ShouldMatchers {
31
31
p.apiVersion should be (" 1.2.3" )
32
32
p.swaggerVersion should be (" 1.2" )
33
33
p.apis.size should be (0 )
34
+ p.authorizations.size should be (0 )
34
35
}
35
36
case _ => fail(" wrong type returned, should be ResourceListing" )
36
37
}
37
38
}
38
39
39
- it should " serialize an ApiListingReference with no apis" in {
40
- val l = ApiListingReference (" /foo/bar" , Some (" the description" ))
41
- write(l) should be (""" {"path":"/foo/bar","description":"the description"}""" )
42
- }
43
-
44
40
it should " deserialize an ResourceListing" in {
45
41
val jsonString = """
46
42
{
@@ -54,7 +50,8 @@ class ResourceListingSerializersTest extends FlatSpec with ShouldMatchers {
54
50
"path":"/c",
55
51
"description":"path c apis"
56
52
}
57
- ]
53
+ ],
54
+ "authorizations": {}
58
55
}
59
56
"""
60
57
val json = parse(jsonString)
@@ -63,15 +60,12 @@ class ResourceListingSerializersTest extends FlatSpec with ShouldMatchers {
63
60
p.apiVersion should be (" 1.2.3" )
64
61
p.swaggerVersion should be (" 1.2" )
65
62
p.apis.size should be (2 )
63
+ p.authorizations.size should be (0 )
66
64
}
67
65
case _ => fail(" wrong type returned, should be ResourceListing" )
68
66
}
69
67
}
70
68
71
- it should " serialize an ApiListingReference" in {
72
- val l = ApiListingReference (" /foo/bar" , Some (" the description" ))
73
- write(l) should be (""" {"path":"/foo/bar","description":"the description"}""" )
74
- }
75
69
}
76
70
77
71
@ RunWith (classOf [JUnitRunner ])
@@ -102,9 +96,52 @@ class ApiListingReferenceSerializersTest extends FlatSpec with ShouldMatchers {
102
96
}
103
97
104
98
@ RunWith (classOf [JUnitRunner ])
105
- class ApiDescriptionSerializersTest extends FlatSpec with ShouldMatchers {
99
+ class ApiListingSerializersTest extends FlatSpec with ShouldMatchers {
106
100
implicit val formats = SwaggerSerializers .formats(" 1.2" )
107
101
102
+ it should " deserialize an ApiListing" in {
103
+ val jsonString = """
104
+ {
105
+ "apiVersion":"1.2.3",
106
+ "swaggerVersion":"1.2",
107
+ "basePath": "/foo/bar",
108
+ "resourcePath": "/a/b",
109
+ "produces": [ "application/json" ],
110
+ "authorizations": {},
111
+ "apis": []
112
+ }
113
+ """
114
+ val json = parse(jsonString)
115
+ json.extract[ApiListing ] match {
116
+ case p : ApiListing => {
117
+ p.apiVersion should be (" 1.2.3" )
118
+ p.swaggerVersion should be (" 1.2" )
119
+ p.basePath should be (" /foo/bar" )
120
+ p.resourcePath should be (" /a/b" )
121
+ p.produces should be (List (" application/json" ))
122
+ p.authorizations.size should be (0 )
123
+ p.models should be (None )
124
+ p.description should be (None )
125
+ p.position should be (0 )
126
+ }
127
+ case _ => fail(" wrong type returned, should be ApiListing" )
128
+ }
129
+ }
130
+
131
+ it should " serialize an ApiListing" in {
132
+ val l = ApiListing (
133
+ apiVersion = " 1.2.3" ,
134
+ swaggerVersion = " 1.2" ,
135
+ basePath = " /foo/bar" ,
136
+ resourcePath = " /a/b"
137
+ )
138
+ write(l) should be (""" {"apiVersion":"1.2.3","resourcePath":"/a/b","swaggerVersion":"1.2","basePath":"/foo/bar"}""" )
139
+ }
140
+ }
141
+
142
+ @ RunWith (classOf [JUnitRunner ])
143
+ class ApiDescriptionSerializersTest extends FlatSpec with ShouldMatchers {
144
+ implicit val formats = SwaggerSerializers .formats(" 1.2" )
108
145
it should " deserialize an ApiDescription with no ops" in {
109
146
val jsonString = """
110
147
{
@@ -151,7 +188,8 @@ class ApiDescriptionSerializersTest extends FlatSpec with ShouldMatchers {
151
188
"enum":["a","b","c"],
152
189
"paramType":"query"
153
190
}
154
- ]
191
+ ],
192
+ "authorizations":{}
155
193
}
156
194
]
157
195
}
@@ -179,6 +217,7 @@ class ApiDescriptionSerializersTest extends FlatSpec with ShouldMatchers {
179
217
m.dataType should be (" string" )
180
218
m.paramType should be (" query" )
181
219
})
220
+ op.authorizations.size should be (0 )
182
221
})
183
222
}
184
223
case _ => fail(" wrong type returned, should be ApiDescription" )
@@ -230,7 +269,8 @@ class OperationSerializersTest extends FlatSpec with ShouldMatchers {
230
269
"enum":["a","b","c"],
231
270
"paramType":"query"
232
271
}
233
- ]
272
+ ],
273
+ "authorizations":{}
234
274
}
235
275
"""
236
276
val json = parse(jsonString)
@@ -252,6 +292,7 @@ class OperationSerializersTest extends FlatSpec with ShouldMatchers {
252
292
m.dataType should be (" string" )
253
293
m.paramType should be (" query" )
254
294
})
295
+ op.authorizations.size should be (0 )
255
296
}
256
297
case _ => fail(" wrong type returned, should be Operation" )
257
298
}
@@ -833,4 +874,4 @@ class AllowableValuesSerializersTest extends FlatSpec with ShouldMatchers {
833
874
val l = AllowableRangeValues (" -1" , " 3" )
834
875
write(l) should be (""" {"valueType":"RANGE","min":"-1","max":"3"}""" )
835
876
}
836
- }
877
+ }
0 commit comments