diff --git a/docs/generators/php-laravel.md b/docs/generators/php-laravel.md
index 9c8665cc52eb..b28504c1d02a 100644
--- a/docs/generators/php-laravel.md
+++ b/docs/generators/php-laravel.md
@@ -40,6 +40,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- DateTime
+- array
- bool
- boolean
- byte
diff --git a/docs/generators/php-lumen.md b/docs/generators/php-lumen.md
index 9242d70ae45e..28f4810873d3 100644
--- a/docs/generators/php-lumen.md
+++ b/docs/generators/php-lumen.md
@@ -40,6 +40,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- DateTime
+- array
- bool
- boolean
- byte
diff --git a/docs/generators/php-mezzio-ph.md b/docs/generators/php-mezzio-ph.md
index 93f31d7fbca2..8460e439084d 100644
--- a/docs/generators/php-mezzio-ph.md
+++ b/docs/generators/php-mezzio-ph.md
@@ -41,6 +41,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- DateTime
+- array
- bool
- boolean
- byte
diff --git a/docs/generators/php-slim-deprecated.md b/docs/generators/php-slim-deprecated.md
index 016ccd242e20..838b14ab7c3b 100644
--- a/docs/generators/php-slim-deprecated.md
+++ b/docs/generators/php-slim-deprecated.md
@@ -40,6 +40,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- DateTime
+- array
- bool
- boolean
- byte
diff --git a/docs/generators/php-slim4.md b/docs/generators/php-slim4.md
index cadaf51e5ff8..5e0ec649254b 100644
--- a/docs/generators/php-slim4.md
+++ b/docs/generators/php-slim4.md
@@ -41,6 +41,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- DateTime
+- array
- bool
- boolean
- byte
diff --git a/docs/generators/php.md b/docs/generators/php.md
index ab4045d604db..8a99d592df2c 100644
--- a/docs/generators/php.md
+++ b/docs/generators/php.md
@@ -41,6 +41,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
- DateTime
+- array
- bool
- boolean
- byte
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java
index d8327a994011..779393af403a 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java
@@ -89,6 +89,7 @@ public AbstractPhpCodegen() {
"float",
"string",
"object",
+ "array",
"DateTime",
"mixed",
"number",
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/AbstractPhpCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/AbstractPhpCodegenTest.java
index 22ecaeb21089..667e91df22e8 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/AbstractPhpCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/php/AbstractPhpCodegenTest.java
@@ -17,10 +17,16 @@
package org.openapitools.codegen.php;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.media.Schema;
+
import org.openapitools.codegen.CodegenConstants;
+import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
+import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.languages.AbstractPhpCodegen;
+import org.openapitools.codegen.TestUtils;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -122,6 +128,24 @@ public static Object[][] composerNames() {
};
}
+ @Test(description = "Issue #8945")
+ public void testArrayOfArrays() {
+ final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue_8945.yaml");
+ final AbstractPhpCodegen codegen = new P_AbstractPhpCodegen();
+
+ Schema test1 = openAPI.getComponents().getSchemas().get("MyResponse");
+ CodegenModel cm1 = codegen.fromModel("MyResponse", test1);
+
+ // Make sure we got the container object.
+ Assert.assertEquals(cm1.getDataType(), "object");
+ Assert.assertEquals(codegen.getTypeDeclaration("MyResponse"), "\\php\\Model\\MyResponse");
+
+ // Assert the array type is properly detected.
+ CodegenProperty cp1 = cm1.vars.get(0);
+ cp1 = codegen.fromProperty("ArrayProp", test1);
+ Assert.assertTrue(cp1.isPrimitiveType);
+ }
+
private static class P_AbstractPhpCodegen extends AbstractPhpCodegen {
@Override
public CodegenType getTag() {
diff --git a/modules/openapi-generator/src/test/resources/3_0/issue_8945.yaml b/modules/openapi-generator/src/test/resources/3_0/issue_8945.yaml
new file mode 100644
index 000000000000..efe6b6d35ddb
--- /dev/null
+++ b/modules/openapi-generator/src/test/resources/3_0/issue_8945.yaml
@@ -0,0 +1,50 @@
+openapi: 3.0.1
+info:
+ title: OpenAPI Petstore
+ description: "for schemas with properties and required ensure correct hasVars, hasRequired, vars, and requiredVars"
+ license:
+ name: Apache-2.0
+ url: https://www.apache.org/licenses/LICENSE-2.0.html
+ version: 1.0.0
+servers:
+ - url: http://petstore.swagger.io:80/v2
+tags: []
+paths:
+ /sut:
+ get:
+ operationId: getArrayOfArrays
+ responses:
+ '200':
+ description: OK
+ schema:
+ $ref: '#/definitions/MyResponse'
+components:
+ schemas:
+ MyResponse:
+ type: object
+ properties:
+ ArrayOfArrays:
+ type: array
+ items:
+ $ref: '#/components/schemas/ArrayProp'
+ ArrayOfObjects:
+ type: array
+ items:
+ $ref: '#/components/schemas/ObjectProp'
+ ArrayOfArrays:
+ type: array
+ items:
+ $ref: '#/components/schemas/ArrayProp'
+ ArrayOfObjects:
+ type: array
+ items:
+ $ref: '#/components/schemas/ObjectProp'
+ ArrayProp:
+ type: array
+ items:
+ type: string
+ ObjectProp:
+ type: object
+ properties:
+ name:
+ type: string
diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/AdditionalPropertiesClass.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/AdditionalPropertiesClass.md
index 577d4a425b92..bcb264218559 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/AdditionalPropertiesClass.md
+++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/AdditionalPropertiesClass.md
@@ -5,6 +5,6 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**map_property** | **array** | | [optional]
-**map_of_map_property** | [**array>**](array.md) | | [optional]
+**map_of_map_property** | **array>** | | [optional]
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfArrayOfNumberOnly.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfArrayOfNumberOnly.md
index d035d7a47076..45f7d3b86150 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfArrayOfNumberOnly.md
+++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayOfArrayOfNumberOnly.md
@@ -4,6 +4,6 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**array_array_number** | [**float[][]**](array.md) | | [optional]
+**array_array_number** | **float[][]** | | [optional]
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayTest.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayTest.md
index 184244105328..8f260b7c9b52 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayTest.md
+++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/ArrayTest.md
@@ -5,7 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**array_of_string** | **string[]** | | [optional]
-**array_array_of_integer** | [**int[][]**](array.md) | | [optional]
-**array_array_of_model** | [**\OpenAPI\Client\Model\ReadOnlyFirst[][]**](array.md) | | [optional]
+**array_array_of_integer** | **int[][]** | | [optional]
+**array_array_of_model** | **\OpenAPI\Client\Model\ReadOnlyFirst[][]** | | [optional]
[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
diff --git a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/MapTest.md b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/MapTest.md
index 7bb07e8451ef..10509cbb6ec1 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/docs/Model/MapTest.md
+++ b/samples/client/petstore/php/OpenAPIClient-php/docs/Model/MapTest.md
@@ -4,7 +4,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
-**map_map_of_string** | [**array>**](array.md) | | [optional]
+**map_map_of_string** | **array>** | | [optional]
**map_of_enum_string** | **array** | | [optional]
**direct_map** | **array** | | [optional]
**indirect_map** | **array** | | [optional]
diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php b/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php
index c8be21f6cc20..bd876d0c289e 100644
--- a/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php
+++ b/samples/client/petstore/php/OpenAPIClient-php/lib/ObjectSerializer.php
@@ -86,7 +86,7 @@ public static function sanitizeForSerialization($data, $type = null, $format = n
foreach ($data::openAPITypes() as $property => $openAPIType) {
$getter = $data::getters()[$property];
$value = $data->$getter();
- if ($value !== null && !in_array($openAPIType, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
+ if ($value !== null && !in_array($openAPIType, ['DateTime', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
$callable = [$openAPIType, 'getAllowableEnumValues'];
if (is_callable($callable)) {
/** array $callable */
@@ -330,7 +330,7 @@ public static function deserialize($data, $class, $httpHeaders = null)
}
/** @psalm-suppress ParadoxicalCondition */
- if (in_array($class, ['DateTime', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
+ if (in_array($class, ['DateTime', 'array', 'bool', 'boolean', 'byte', 'double', 'float', 'int', 'integer', 'mixed', 'number', 'object', 'string', 'void'], true)) {
settype($data, $class);
return $data;
}