Hi Restler/Swagger friends,
I'm facing a problem when i trying to post a url (ex. /home/ahmad/) as follow:
{
"error": {
"code": 400,
"message": "Bad Request: `url` is required but missing."
},
"debug": {
"source": "Validator.php:26 at validate stage",
"stages": {
"success": [
"get",
"route",
"negotiate"
],
"failure": [
"validate",
"message"
]
}
}
}
my code for test is:
/**
* POST url
*
* @param string $url {@from url} url for test
*
* @return string
*/
function post_url($url) {
return $url;
}
I tried debugging the problem and discovered that url value is received as NULL before the Validator is applied
How i can solve such this problem?
I can see few problems with your approach
First, if you want to map a parameter to url you have to use {@from path}
not {@from url}
Then if your variable is going to contain slashes they should ideally be mapped to query string or body as the slashes in the url path will be understood as many parameters by Restler
If you must accept it part of the url, you can use the wildcard routing as shown below
/**
* POST url
*
* @return string
*
* @url POST url/*
*/
function postUrl() {
return implode(',', func_get_args());
}