|
2 | 2 |
|
3 | 3 | import static org.testng.Assert.assertEquals; |
4 | 4 | import static org.testng.Assert.assertTrue; |
| 5 | +import static org.testng.AssertJUnit.assertNotNull; |
5 | 6 |
|
| 7 | +import io.swagger.models.ArrayModel; |
| 8 | +import io.swagger.models.Model; |
6 | 9 | import io.swagger.models.Swagger; |
7 | 10 | import io.swagger.models.properties.ObjectProperty; |
8 | 11 | import io.swagger.models.properties.MapProperty; |
|
12 | 15 | import io.swagger.util.ResourceUtils; |
13 | 16 |
|
14 | 17 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 18 | +import io.swagger.util.Yaml; |
15 | 19 | import org.testng.annotations.Test; |
16 | 20 |
|
17 | 21 | import java.io.IOException; |
@@ -117,4 +121,19 @@ public void testNestedUntypedProperty() throws IOException { |
117 | 121 | assertTrue(additionalProperties instanceof UntypedProperty); |
118 | 122 | assertEquals(additionalProperties.getDescription(), "map value"); |
119 | 123 | } |
| 124 | + |
| 125 | + @Test(description = "it should deserialize an array untyped") |
| 126 | + public void testArrayUntypedModel() throws IOException { |
| 127 | + final String json = "{\n" + |
| 128 | + " \"description\":\"top level object\",\n" + |
| 129 | + " \"items\":{}" + |
| 130 | + "}"; |
| 131 | + final Model result = m.readValue(json, Model.class); |
| 132 | + assertTrue(result instanceof ArrayModel); |
| 133 | + |
| 134 | + final ArrayModel array = (ArrayModel) result; |
| 135 | + assertEquals(array.getType(),"array"); |
| 136 | + assertEquals(array.getDescription(), "top level object"); |
| 137 | + assertNotNull(array.getItems()); |
| 138 | + } |
120 | 139 | } |
0 commit comments