How can i define an array as a property in model class?
let me conclude what i did...
my model class that contains an array
class Author {
/**
* @var string {@from body}
* name of the Author {@required true}
*/
public $name = 'Name';
/**
* @var string {@type email} {@from body}
* email id of the Author
*/
public $email = '[email protected]';
/**
* @var array $arr {@type array} array of person
* {@required true}
*/
public $arr = array();
}
my function to test throw restler is:
/**
* POST
* post Author
*
* @param {@type Author} $a
*
* @return Author
*/
function postAuthor(Author $a) {
return $a;
}
when i try to test and class function remotely throw index.html it returns as value:
{
"name":"",
"email":"",
"arr":""
}
what i need is to return it as follow:
{
"name":"",
"email":"",
"arr":[]
}
How and what i have to do to make that?
I understand that you are talking about Restler Explorer showing the request body with
arr
as a string instead of arrayIt is because the default response is created as a simple helper to reduce typing and it does not support complex types yet
We are adding Swagger 1.2 support in the new explorer that we are currently working on
It will include an advanced version of the helper to build the request body properly
Update to answer further
If you use Restler 3.0 RC5 (currently only available in
v3
branch) and comment your api model class as shown below you can get it working