Luracast / Restler

Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and/or RESTful API
http://luracast.com/products/restler/
GNU Lesser General Public License v2.1
1.36k stars 316 forks source link

Error when adding @param annotation #374

Closed dodyagung closed 9 years ago

dodyagung commented 9 years ago

Hi, I created a login function in my auth class. I added two @.param here :

/**
     * @param String $username
     * @param String $password
     * 
     * @todo Tanya ke wanda, return apa aja yg dibutuhkan
     * 
     * @return Object
     * @throws RestException
     */
    function postLogin($username, $password) { ... }

and the result is :

"error": {
        "code": 400,
        "message": "Bad Request: Invalid value specified for `username`"
    },

when I deleted the @.param annotation, it works.

/**
     * @todo Tanya ke wanda, return apa aja yg dibutuhkan
     * 
     * @return Object
     * @throws RestException
     */
    function postLogin($username, $password) { ... }

and the result is :

{
    "success": {
        "message": "Login berhasil"
    },
    "nama": "dody",
    "token": "N2uHe30QA7j8TashzUGi"
}

I don't know is this a bug or maybe I do a mistake. Can you explain it to me?

Thanks!

Arul- commented 9 years ago

How do you pass the username and password to the API?

Which version of Restler is being used RC6 or RC5 and below?

dodyagung commented 9 years ago

I passed it by POST method like the function name (POSTlogin) I am using RC 5

Arul- commented 9 years ago

I guess the problem is defining the type as String (note the capital S) whereas php strings should be typed as `string' ( all lower case)

Please try that and re-open this issue if it still fails