Luracast / Restler

Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and/or RESTful API

Home Page:http://luracast.com/products/restler/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to describe response type

camlafit opened this issue · comments

commented

Hello

Sorry to open about this but I've not found information code source and official documentation. How could we provide a response description more accurate ?

By default Explorer display a simple model schema

[ "string" ]

Capture d’écran de 2021-07-08 15-38-07

We can improve this result if we type phpdoc return

    /**
     * @return array {@type int}
     * /
    public function get($id) {}

Capture d’écran de 2021-07-08 15-39-34

if we set any other value than array as int or string, model schema is removed
if we set some value in {@type } it's broken also as Object , array

How can provide a more accurate description about as we can get with {@params} description ?

As :
Capture d’écran de 2021-07-08 15-43-55

Thanks a lot

commented

related to #565

commented

Note, following https://github.com/Luracast/Restler/blob/master/src/Explorer/v2/Explorer.php#L457, some {@type} could be provided. Following code, we could set

  • @return array Description {@type associative}
  • @return array Description {@type indexed}
  • @return array Description {@type AnyObject}
  • @return antype Description

With {@type indexed} return it's forced to string
If array is not set or different, in this case it's forced to string

commented

Check this with the latest commits in the V5 branch. Hope its resolved

commented

now available in 5.0.7

commented

Hello

This use case broke again :

@return array qezaezaezaezza {@type array}

Thanks

commented

That use case is not supported by swagger. You can do one of the following instead

  1. @return array description {@type indexed} indexed array
  2. @return array description {@type associative} associative array / object
  3. @return object[] description array of objects
  4. @return string[] description array of strings