swagger-api / swagger-api/swagger-codegen

[PHP] Empty Response for api call that has a response

Open
#8,723 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

There is an empty response when calling searchCustomers. I traced the code and the response in json is correct but appears to have an issue deserializing and not having data back as objects/arrays

Swagger-codegen version

3

Swagger declaration file content or url

https://demo.phppointofsale.com/application/controllers/api/

Command line used for generation

php codegen

java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate -i https://demo.phppointofsale.com/application/controllers/api/ -l php -o /Users/cmuench/Desktop/api

Steps to reproduce
$apiInstance = new Swagger\Client\Api\CustomersApi(
    // 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(),
    $config
);
$search = "Chris"; // string | Search customers
$search_field = "first_name"; // string | Search specific field
$offset = 0; // int | Offset to list customers
$limit = 20; // int | Number of customers to get

try {

   //always empty
    $result = $apiInstance->searchCustomers($search, $search_field, $offset, $limit);
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling CustomersApi->searchCustomers: ', $e->getMessage(), PHP_EOL;
}
Related issues/PRs
Suggest a fix/enhancement

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the generated PHP client command against the linked API declaration and call CustomersApi::searchCustomers with the supplied parameters. Inspect the response deserialization path and compare it with the reported correct JSON response. Done means searchCustomers returns populated objects or arrays instead of an empty result.

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
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.