swagger-api / swagger-api/swagger-codegen
[PHP] Class 'null' not found
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I have this error:
Fatal error: Uncaught Error: Class 'null' not found in /Users/mickael/Desktop/swagger-codegen/SwaggerClient-php/lib/ObjectSerializer.php:294
Stack trace:
#0 /Users/mickael/Desktop/swagger-codegen/SwaggerClient-php/lib/ObjectSerializer.php(247): Swagger\Client\ObjectSerializer::deserialize(Object(stdClass), 'null', NULL)
#1 /Users/mickael/Desktop/swagger-codegen/SwaggerClient-php/lib/ObjectSerializer.php(311): Swagger\Client\ObjectSerializer::deserialize(Array, 'null[]', NULL)
#2 /Users/mickael/Desktop/swagger-codegen/SwaggerClient-php/lib/Api/DefaultApi.php(157): Swagger\Client\ObjectSerializer::deserialize(Object(stdClass), '\\Swagger\\Client...', Array)
#3 /Users/mickael/Desktop/swagger-codegen/SwaggerClient-php/lib/Api/DefaultApi.php(98): Swagger\Client\Api\DefaultApi->vaultPostWithHttpInfo(Object(Swagger\Client\Model\VaultRequest))
#4 /Users/mickael/Desktop/swagger-codegen/SwaggerClient-php/test.php(18): Swagger\Client\Api\DefaultApi->vaultPost(Object(S in /Users/mickael/Desktop/swagger-codegen/SwaggerClient-php/lib/ObjectSerializer.php on line 294
Swagger-codegen version
swagger-codegen version: 2.3.1
Swagger declaration file content or url
https://gist.github.com/mickaelmonsieur/6f761d5f9f1077b49fe3f7a95a4a78d0
Command line used for generation
swagger-codegen generate -i /tmp/swagger.json -l php -o /Users/mickael/Desktop/swagger-codegen/
Steps to reproduce
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new Swagger\Client\Api\DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
new GuzzleHttp\Client(['cert' => ['../../certs/xxxxxxxxxx.net.pem',
'PassW0rdXXX']]),
$config
);
$data = array('source_id' => 40, 'allow_partial_update' => false);
$json_vault_request = new \Swagger\Client\Model\VaultRequest($data); // \Swagger\Client\Model\VaultRequest |
echo $json_vault_request->__toString();
try {
$result = $apiInstance->vaultPost($json_vault_request);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling DefaultApi->vaultPost: ', $e->getMessage(), PHP_EOL;
}
?>
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 SwaggerClient-php/lib/ObjectSerializer.php, especially the deserialize calls around lines 247, 294, and 311, and reproduce the failure using the linked declaration and PHP example. Trace how the generated client handles null and null[] response types; done means the reported request no longer raises Class 'null' not found, with regression coverage for the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100