|
17 | 17 |
|
18 | 18 | package org.openapitools.codegen.php; |
19 | 19 |
|
| 20 | +import io.swagger.v3.oas.models.OpenAPI; |
| 21 | +import io.swagger.v3.oas.models.media.Schema; |
| 22 | + |
20 | 23 | import org.openapitools.codegen.CodegenConstants; |
| 24 | +import org.openapitools.codegen.CodegenModel; |
21 | 25 | import org.openapitools.codegen.CodegenOperation; |
| 26 | +import org.openapitools.codegen.CodegenProperty; |
22 | 27 | import org.openapitools.codegen.CodegenType; |
23 | 28 | import org.openapitools.codegen.languages.AbstractPhpCodegen; |
| 29 | +import org.openapitools.codegen.TestUtils; |
24 | 30 | import org.testng.Assert; |
25 | 31 | import org.testng.annotations.DataProvider; |
26 | 32 | import org.testng.annotations.Test; |
@@ -122,6 +128,24 @@ public static Object[][] composerNames() { |
122 | 128 | }; |
123 | 129 | } |
124 | 130 |
|
| 131 | + @Test(description = "Issue #8945") |
| 132 | + public void testArrayOfArrays() { |
| 133 | + final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_8945.yaml"); |
| 134 | + final AbstractPhpCodegen codegen = new P_AbstractPhpCodegen(); |
| 135 | + |
| 136 | + Schema test1 = openAPI.getComponents().getSchemas().get("MyResponse"); |
| 137 | + CodegenModel cm1 = codegen.fromModel("MyResponse", test1); |
| 138 | + |
| 139 | + // Make sure we got the container object. |
| 140 | + Assert.assertEquals(cm1.getDataType(), "object"); |
| 141 | + Assert.assertEquals(codegen.getTypeDeclaration("MyResponse"), "\\php\\Model\\MyResponse"); |
| 142 | + |
| 143 | + // Assert the array type is properly detected. |
| 144 | + CodegenProperty cp1 = cm1.vars.get(0); |
| 145 | + cp1 = codegen.fromProperty("ArrayProp", test1); |
| 146 | + Assert.assertTrue(cp1.isPrimitiveType); |
| 147 | + } |
| 148 | + |
125 | 149 | private static class P_AbstractPhpCodegen extends AbstractPhpCodegen { |
126 | 150 | @Override |
127 | 151 | public CodegenType getTag() { |
|
0 commit comments