|
8 | 8 | import io.swagger.v3.oas.models.media.ObjectSchema; |
9 | 9 | import io.swagger.v3.oas.models.media.Schema; |
10 | 10 | import io.swagger.v3.oas.models.responses.ApiResponse; |
| 11 | +import org.testng.Assert; |
11 | 12 | import org.testng.annotations.Test; |
12 | 13 |
|
13 | 14 | import static io.swagger.v3.core.util.TestUtils.normalizeLineEnds; |
@@ -83,6 +84,38 @@ public class MapPropertyDeserializerTest { |
83 | 84 | " ]\n" + |
84 | 85 | "}"; |
85 | 86 |
|
| 87 | + private static final String jsonAdditionalPropertiesBooleanTrue = "{\n" + |
| 88 | + " \"tags\": [\n" + |
| 89 | + " \"store\"\n" + |
| 90 | + " ],\n" + |
| 91 | + " \"summary\": \"Returns pet inventories by status\",\n" + |
| 92 | + " \"description\": \"Returns a map of status codes to quantities\",\n" + |
| 93 | + " \"operationId\": \"getInventory\",\n" + |
| 94 | + " \"produces\": [\n" + |
| 95 | + " \"application/json\"\n" + |
| 96 | + " ],\n" + |
| 97 | + " \"parameters\": [],\n" + |
| 98 | + " \"responses\": {\n" + |
| 99 | + " \"200\": {\n" + |
| 100 | + " \"description\": \"successful operation\",\n" + |
| 101 | + " \"content\": {\n" + |
| 102 | + " \"*/*\": {\n" + |
| 103 | + " \"schema\": {\n" + |
| 104 | + " \"type\": \"object\",\n" + |
| 105 | + " \"x-foo\": \"vendor x\",\n" + |
| 106 | + " \"additionalProperties\": true\n" + |
| 107 | + " }\n" + |
| 108 | + " }\n" + |
| 109 | + " }\n" + |
| 110 | + " }\n" + |
| 111 | + " },\n" + |
| 112 | + " \"security\": [\n" + |
| 113 | + " {\n" + |
| 114 | + " \"api_key\": []\n" + |
| 115 | + " }\n" + |
| 116 | + " ]\n" + |
| 117 | + "}"; |
| 118 | + |
86 | 119 | @Test(description = "it should deserialize a response per #1349") |
87 | 120 | public void testMapDeserialization() throws Exception { |
88 | 121 |
|
@@ -110,6 +143,18 @@ public void testBooleanAdditionalPropertiesDeserialization() throws Exception { |
110 | 143 | assertTrue(responseSchema instanceof ObjectSchema); |
111 | 144 |
|
112 | 145 | assertTrue(responseSchema.getAdditionalProperties() instanceof Boolean); |
| 146 | + Assert.assertFalse((Boolean)responseSchema.getAdditionalProperties()); |
| 147 | + |
| 148 | + operation = Json.mapper().readValue(jsonAdditionalPropertiesBooleanTrue, Operation.class); |
| 149 | + response = operation.getResponses().get("200"); |
| 150 | + assertNotNull(response); |
| 151 | + |
| 152 | + responseSchema = response.getContent().get("*/*").getSchema(); |
| 153 | + assertNotNull(responseSchema); |
| 154 | + assertTrue(responseSchema instanceof MapSchema); |
| 155 | + |
| 156 | + assertTrue(responseSchema.getAdditionalProperties() instanceof Boolean); |
| 157 | + Assert.assertTrue((Boolean)responseSchema.getAdditionalProperties()); |
113 | 158 | } |
114 | 159 |
|
115 | 160 | @Test(description = "it should serialize a boolean additionalProperties") |
|
0 commit comments