Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public String toDefaultValue(CodegenProperty codegenProperty, Schema schema) {
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);

if (schema.getDefault() != null) { // array schema has default value
return "[" + schema.getDefault().toString() + "]";
return schema.getDefault().toString();
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: Array defaults are emitted using raw Java toString() and injected unescaped into PHP templates, which can produce invalid PHP literals for string/object array defaults.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpNextgenClientCodegen.java, line 254:

<comment>Array defaults are emitted using raw Java `toString()` and injected unescaped into PHP templates, which can produce invalid PHP literals for string/object array defaults.</comment>

<file context>
@@ -251,7 +251,7 @@ public String toDefaultValue(CodegenProperty codegenProperty, Schema schema) {
 
             if (schema.getDefault() != null) { // array schema has default value
-                return "[" + schema.getDefault().toString() + "]";
+                return schema.getDefault().toString();
             } else if (schema.getItems().getDefault() != null) { // array item schema has default value
                 return "[" + toDefaultValue(schema.getItems()) + "]";
</file context>
Fix with Cubic

} else if (schema.getItems().getDefault() != null) { // array item schema has default value
return "[" + toDefaultValue(schema.getItems()) + "]";
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**array_string_enum_ref_default** | [**\OpenAPI\Client\Model\StringEnumRef[]**](StringEnumRef.md) | | [optional] [default to [["success","failure"]]]
**array_string_enum_default** | **string[]** | | [optional] [default to [["success","failure"]]]
**array_string_default** | **string[]** | | [optional] [default to [["failure","skipped"]]]
**array_integer_default** | **int[]** | | [optional] [default to [[1,3]]]
**array_string_enum_ref_default** | [**\OpenAPI\Client\Model\StringEnumRef[]**](StringEnumRef.md) | | [optional] [default to ["success","failure"]]
**array_string_enum_default** | **string[]** | | [optional] [default to ["success","failure"]]
**array_string_default** | **string[]** | | [optional] [default to ["failure","skipped"]]
**array_integer_default** | **int[]** | | [optional] [default to [1,3]]
**array_string** | **string[]** | | [optional]
**array_string_nullable** | **string[]** | | [optional]
**array_string_extension_nullable** | **string[]** | | [optional]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | Query | [optional]
**outcomes** | **string[]** | | [optional] [default to [["SUCCESS","FAILURE"]]]
**outcomes** | **string[]** | | [optional] [default to ["SUCCESS","FAILURE"]]

[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ public static function getArrayStringEnumDefaultAllowableValues()
*/
public function __construct(?array $data = null)
{
$this->setIfExists('array_string_enum_ref_default', $data ?? [], [["success","failure"]]);
$this->setIfExists('array_string_enum_default', $data ?? [], [["success","failure"]]);
$this->setIfExists('array_string_default', $data ?? [], [["failure","skipped"]]);
$this->setIfExists('array_integer_default', $data ?? [], [[1,3]]);
$this->setIfExists('array_string_enum_ref_default', $data ?? [], ["success","failure"]);
$this->setIfExists('array_string_enum_default', $data ?? [], ["success","failure"]);
$this->setIfExists('array_string_default', $data ?? [], ["failure","skipped"]);
$this->setIfExists('array_integer_default', $data ?? [], [1,3]);
$this->setIfExists('array_string', $data ?? [], null);
$this->setIfExists('array_string_nullable', $data ?? [], null);
$this->setIfExists('array_string_extension_nullable', $data ?? [], null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public static function getOutcomesAllowableValues()
public function __construct(?array $data = null)
{
$this->setIfExists('id', $data ?? [], null);
$this->setIfExists('outcomes', $data ?? [], [["SUCCESS","FAILURE"]]);
$this->setIfExists('outcomes', $data ?? [], ["SUCCESS","FAILURE"]);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**array_string_enum_ref_default** | [**\OpenAPI\Client\Model\StringEnumRef[]**](StringEnumRef.md) | | [optional] [default to [["success","failure"]]]
**array_string_enum_default** | **string[]** | | [optional] [default to [["success","failure"]]]
**array_string_default** | **string[]** | | [optional] [default to [["failure","skipped"]]]
**array_integer_default** | **int[]** | | [optional] [default to [[1,3]]]
**array_string_enum_ref_default** | [**\OpenAPI\Client\Model\StringEnumRef[]**](StringEnumRef.md) | | [optional] [default to ["success","failure"]]
**array_string_enum_default** | **string[]** | | [optional] [default to ["success","failure"]]
**array_string_default** | **string[]** | | [optional] [default to ["failure","skipped"]]
**array_integer_default** | **int[]** | | [optional] [default to [1,3]]
**array_string** | **string[]** | | [optional]
**array_string_nullable** | **string[]** | | [optional]
**array_string_extension_nullable** | **string[]** | | [optional]
Expand Down
2 changes: 1 addition & 1 deletion samples/client/echo_api/php-nextgen/docs/Model/Query.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**id** | **int** | Query | [optional]
**outcomes** | **string[]** | | [optional] [default to [["SUCCESS","FAILURE"]]]
**outcomes** | **string[]** | | [optional] [default to ["SUCCESS","FAILURE"]]

[[Back to Model list]](../../README.md#models) [[Back to API list]](../../README.md#endpoints) [[Back to README]](../../README.md)
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,10 @@ public static function getArrayStringEnumDefaultAllowableValues()
*/
public function __construct(?array $data = null)
{
$this->setIfExists('array_string_enum_ref_default', $data ?? [], [["success","failure"]]);
$this->setIfExists('array_string_enum_default', $data ?? [], [["success","failure"]]);
$this->setIfExists('array_string_default', $data ?? [], [["failure","skipped"]]);
$this->setIfExists('array_integer_default', $data ?? [], [[1,3]]);
$this->setIfExists('array_string_enum_ref_default', $data ?? [], ["success","failure"]);
$this->setIfExists('array_string_enum_default', $data ?? [], ["success","failure"]);
$this->setIfExists('array_string_default', $data ?? [], ["failure","skipped"]);
$this->setIfExists('array_integer_default', $data ?? [], [1,3]);
$this->setIfExists('array_string', $data ?? [], null);
$this->setIfExists('array_string_nullable', $data ?? [], null);
$this->setIfExists('array_string_extension_nullable', $data ?? [], null);
Expand Down
2 changes: 1 addition & 1 deletion samples/client/echo_api/php-nextgen/src/Model/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public static function getOutcomesAllowableValues()
public function __construct(?array $data = null)
{
$this->setIfExists('id', $data ?? [], null);
$this->setIfExists('outcomes', $data ?? [], [["SUCCESS","FAILURE"]]);
$this->setIfExists('outcomes', $data ?? [], ["SUCCESS","FAILURE"]);
}

/**
Expand Down