swagger-api / swagger-api/swagger-codegen
[PHP] deserializing objects with 400 response
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
I wanted to catch my ApiException, but in eventsGetWithHttpInfo() method I found bug.
When I try $e->getResponseObject() from my Error model, I will have empty fields in this model.
This code in generated Api class:
catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\afficheapiClient\Model\Events',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\afficheapiClient\Model\Error',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
throw $e;
}
I get into case 400 and in ObjectSerializer::deserialize method $data argument with $e->getResponseHeaders() should have stbObject type, but it is string.
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 in the generated eventsGetWithHttpInfo() method and follow its 400 ApiException path into ObjectSerializer::deserialize(), using the Error model and response headers shown in the report. Reproduce the 400 response and verify that getResponseObject() contains populated Error fields rather than an empty model.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100