Model description for arbitrary response

21 views
Skip to first unread message

Moon K

unread,
Feb 6, 2015, 7:58:45 PM2/6/15
to guz...@googlegroups.com
Hello,

I'm struggling with guzzle service description to work with a list of objects.

The following code works as expected.

php

$product = new stdClass;
$product->price = 18;

echo json_encode([$product, $product]);

guzzle service description model section

'models' => [
    'products' => [
         'type' => 'object',
         'additionalProperties' => [
              'location' => 'json'
          ]
     ]
]

outputs

array:2 [▼
  0 => array:1 [▼
    "price" => "18.00"
  ]
  1 => array:1 [▼
    "price" => "18.00"
  ]
]

now..how do I write a model description when I have the following response from PHP?

$product = new stdClass;
$product->price = "18.00";

echo json_encode(['products'=>[$product, $product]]);
Reply all
Reply to author
Forward
0 new messages