I have below JSON Data for rest API
{"region_id":"475","city":"city","item":[{"qty":"1","weight":"","price":"10.0000","sku":"test"}]}
and i wann to create api class
I do like this
/**
 * @api
 * @param string $city
 * @param string $region_id
 * @param array $item
 * @return [].
 */
 public function estimate($city,$region_id,$item);
But return Class array does not exist also I use string [] and I get the same error. How I can pass an array as parameters?
1 Answer 1
pass return type @return array
Update your code with this solution :
/**
 * @api
 * @param string $city
 * @param string $region_id
 * @param array $item
 * @return array
 */
 public function estimate($city,$region_id,$item);
Valid scalar types include: mixed (or anyType), bool (or boolean), str (or string), integer (or int), float, and double
Any parameters or return values of type array can be denoted by following any of the previous types by an empty set of square brackets []
@return array|int|string|bool|float Scalar or array of scalars 
Reference
- 
 you're welcome :)Aditya Shah– Aditya Shah2018年10月08日 11:53:53 +00:00Commented Oct 8, 2018 at 11:53