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 315 forks source link

How to describe response type #658

Closed camlafit closed 3 years ago

camlafit commented 3 years ago

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

camlafit commented 3 years ago

related to #565

camlafit commented 3 years ago

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

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

Arul- commented 3 years ago

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

Arul- commented 3 years ago

now available in 5.0.7

camlafit commented 3 years ago

Hello

This use case broke again :

@return array qezaezaezaezza {@type array}

Thanks

Arul- commented 3 years ago

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