1

I am using a php client generated with swagger codegen 2.3.1. also tried 2.4.0_snapshot, still has the same error. the swagger.json used for generation can be found here

I am trying to use a generated post function that has one parameter of type int[].

according to the generated documentation it should be used like this

$apiInstance = new Swagger\Client\Api\UniverseApi();
$ids = array(new \Swagger\Client\Model\int[]());
$datasource = "tranquility";
$result = $apiInstance->postUniverseNames($ids, $datasource);

if i define $ids like that, it give me a syntax error, unexpected '[', expecting ')'

If I make $ids an array, eg.:

array(2) {
  [0]=>
  int(96305152)
  [1]=>
  int(96075776)
}

it throws an exception:

Exception: Invalid resource type: array.

Eddie
  • 26,593
  • 6
  • 36
  • 58
jjbbss
  • 139
  • 2
  • 15

2 Answers2

0

Have you tried $ids = array(new \Swagger\Client\Model\int()); ?

Tamas Szoke
  • 5,426
  • 4
  • 24
  • 39
0

Turns out is was a guzzle problem and nothing with the generated client. It's similar to this solution, simply encode the array as json:

$ids = json_encode(array(new \Swagger\Client\Model\int[]()));

or

$result = $apiInstance->postUniverseNames(json_encode($ids), $datasource);
jjbbss
  • 139
  • 2
  • 15