OpenAPITools / OpenAPITools/openapi-generator
[BUG][PHP] Invalid array 'mixed[]
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I generated a client in PHP for the Azuracast API, and I am getting "Invalid array 'mixed[]" when using the submitSongRequest endpoint. I've followed all of the instructions, but the error occurs on the second request if it's the same song in the span of a few minutes.
I believe this could be an issue with the generator, or it is a problem with the Azuracast OpenAPI.yml file, here is the link to the Swagger page: https://www.azuracast.com/api/
Here is what the output is for 200 (Music submission success):
{
"success": true,
"message": "Your request has been submitted and will be played soon.",
"formatted_message": "Your request has been submitted and will be played soon."
}
Here is the same response represented in the client
AzuraCast\Model\ApiStatus {#571 ▼ // app\Livewire\Main\Request\Create.php:58
#openAPINullablesSetToNull: []
#container: array:3 [▼
"success" => true
"message" => "Your request has been submitted and will be played soon."
"formatted_message" => "Your request has been submitted and will be played soon."
]
}
Here is what the output is for 500 (Music submission failed):
{
"code": 500,
"type": "CannotCompleteActionException",
"message": "Cannot submit request: This song was already requested and will play soon.",
"formatted_message": "Cannot submit request: This song was already requested and will play soon.",
"extra_data": {
"class": "CannotCompleteActionException",
"file": "/var/azuracast/www/backend/src/Exception/Http/CannotCompleteActionException.php",
"line": 26
},
"success": false
}
Here is the same response represented in the client
{#573 ▼ // vendor\lexiandev\azuracast-php-api-client\src\ObjectSerializer.php:412
+"class": "CannotCompleteActionException"
+"file": "/var/azuracast/www/backend/src/Exception/Http/CannotCompleteActionException.php"
+"line": 26
}
Is this normal or an issue with their openapi.yml? that's where I'm mainly confused at, I hope someone can help me out, thanks in advance!
openapi-generator version
7.7.0
OpenAPI declaration file content or url
https://raw.githubusercontent.com/AzuraCast/AzuraCast/main/web/static/openapi.yml
Generation Details
Steps to reproduce
- Create a new, empty project
- Run the following command to install the package:
composer require lexiandev/azuracast-php-api-client - Copy the following code into an empty php document
<?php
require_once(__DIR__ . '/../vendor/autoload.php');
$config = AzuraCast\Configuration::getDefaultConfiguration();
$apiInstance = new AzuraCast\Api\StationsSongRequestsApi(
new GuzzleHttp\Client(),
$config
);
$station_id = "azuratest_radio";
// Let's get a song's request id
try {
$request_id = $apiInstance->getRequestableSongs($station_id)[0]->getRequestId();
} catch (Exception $e) {
print_r($e);
}
// Let's submit a song request
try {
$result = $apiInstance->submitSongRequest($station_id, $request_id);
print_r($result);
} catch (Exception $e) {
print_r($e);
}
Related issues/PRs
#8943
Suggest a fix
Well, according to Google Gemini,
"the "Class not found 'mixed[]'" error you're encountering likely stems from how OpenAPI Generator handles the extra_data field in the Api_Error response structure. Since this field is defined as an array with unspecified item types (mixed[]), the generator might try to create a corresponding PHP class that doesn't exist, leading to the error.
Additionally, some of the configuration options used during client generation, such as allowUnicodeIdentifiers=false and disallowAdditionalPropertiesIfNotPresent=true, could potentially contribute to issues or unexpected behavior if the API specification or responses deviate from the assumed structure."
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked openapi.yml, the submitSongRequest reproduction, and the generated ObjectSerializer.php location reported at line 412. Run the listed Composer setup with OpenAPI Generator 7.7.0 and compare the successful and failed responses. Done means identifying whether the invalid mixed[] handling comes from the specification or PHP generation and documenting a reproducible fix path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, php
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100