swagger-api / swagger-api/swagger-codegen
[PHP] Class "" not found
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I generated a PHP API Client for the Azuracast API, and it works well, but some endpoints give the error message "Class "" not found" when I try to use the API via the client, some classes work without issue, but for example, StationsSongRequestsApi > getRequestableSongsWithHttpInfo where it will respond with the error message above. I need it as I can't really utilize the API without it, and I'm not sure what the issue is. I've tried to regenerate the client multiple times, but the issue persists. I'm not sure if it's an issue with the swagger file or the codegen itself.
Also, here is the actual project.
Swagger-codegen version
3.0.61
Swagger declaration file content or url
https://raw.githubusercontent.com/AzuraCast/AzuraCast/main/web/static/openapi.yml
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i https://raw.githubusercontent.com/AzuraCast/AzuraCast/main/web/static/openapi.yml -l php -o output/azuracast-php-client3 -c ./config.json
Steps to reproduce
- Install the package via composer
- In a new PHP file, require the autoload.php file
- Create a new instance of the client
- Call the method
getRequestableSongsfrom theStationsSongRequestsApiclass
require_once __DIR__ . '/vendor/autoload.php';
use AzuraCast\Api\StationsSongRequestsApi;
use AzuraCast\Configuration;
use AzuraCast\ApiClient;
$config = Configuration::getDefaultConfiguration();
$apiInstance = new StationsSongRequestsApi(new ApiClient($config));
try {
$result = $apiInstance->getRequestableSongs();
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling StationsSongRequestsApi->getRequestableSongs: ', $e->getMessage(), PHP_EOL;
}
also here is the config:
{
"invokerPackage": "AzuraCast",
"apiPackage": "Client\\Api",
"modelPackage": "Client\\Model",
"packagePath": "Azuracast",
"srcBasePath": "src",
"gitUserId": "Lexian-droid",
"gitRepoId": "azuracast-php-client",
"artifactVersion": "1.0.2",
"hideGenerationTimestamp": true
}
Related issues/PRs
#8380
This is the closest issue I could find, but it's not the same issue. (The issue states it returns "Null" but my issue returns an empty string.)
Suggest a fix/enhancement
Not sure what the issue is, but I think it might be an issue with the codegen itself, as the classes are generated, but some of them are not found when trying to use them. I've followed the documentation and the examples provided, but I'm not sure what the issue is.
The error is from: azuracast-php-client\src\ObjectSerializer.php
on line 298, specifically with
// If a discriminator is defined and points to a valid subclass, use it.
$discriminator = $class::DISCRIMINATOR;
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 generated azuracast-php-client/src/ObjectSerializer.php at line 298 and trace the getRequestableSongs call from StationsSongRequestsApi. Compare the generated classes used by this endpoint with one that works, using the linked OpenAPI document and the provided generation command. Done means the reproduced request no longer raises Class "" not found and the relevant generated-client behavior is covered by a regression test.
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
- 35/100