owncloud / owncloud/libre-graph-api-php
Generated PHP has strange if-statements
Open
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Example from https://github.com/owncloud/libre-graph-api-php/blob/main/lib/Api/TagsApi.php getTagsWithHttpInfo()
switch($statusCode) {
case 200:
if ('\OpenAPI\Client\Model\CollectionOfTags' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\CollectionOfTags' !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CollectionOfTags', []),
$response->getStatusCode(),
$response->getHeaders()
];
default:
if ('\OpenAPI\Client\Model\OdataError' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\OpenAPI\Client\Model\OdataError' !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\OdataError', []),
$response->getStatusCode(),
$response->getHeaders()
];
}
$returnType = '\OpenAPI\Client\Model\CollectionOfTags';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== 'string') {
$content = json_decode($content);
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
Note: the first PHP was generated by https://github.com/owncloud/libre-graph-api/pull/113
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
The example is in lib/Api/TagsApi.php, in getTagsWithHttpInfo(); start by comparing this generated method with the generation inputs or templates used by the PHP client. Determine the intended handling for CollectionOfTags, OdataError, and the return type, then verify that regenerated output no longer contains the reported conditions.
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
- Needs clarification
- Newbie friendliness
- 35/100