编程语言
首页 > 编程语言> > php – Restler:复杂对象类型作为参数

php – Restler:复杂对象类型作为参数

作者:互联网

你好Restler朋友,

我目前正在尝试切换到Restler作为我们的主要Rest-Framework.真正推动我决定的是宽松的合规性.我发现为一个长大的系统提供一个很好的自动生成文档是非常重要的.

所以,我的问题是我似乎无法找到一种方法来使用“复杂对象”作为swagger中指定的post参数:https://github.com/wordnik/swagger-core/wiki/Parameters.

当然,您可以从“post assoc array”中检索所有内容,然后根据对象结构进行验证,但这不会被记录,客户端也不会知道他期望的结构.因此,我必须写一个规范.用手…

示例:

/**
 * Create a new Account, based on the structure of the Account Object
 *
 * @param Account $account {@from body}
 *
 * @return string
 *
 */
protected function post(Account $account){...}

这将简单地作为未定义的“对象”放在resource.json中,而不是作为链接到Account对象的“复杂类型”(顺便说一下,这对返回的对象非常有用)

Resource.json

"parameters": [
    {
    "name": "REQUEST_BODY",
    "description": "Paste JSON data here with the following property.<hr/><mark>account</mark> <i>(required)</i>: add <mark>@param {type} $account {comment}</mark> to describe here",
    "paramType": "body",
    "required": true,
    "allowMultiple": false,
    "dataType": "Object",
    "defaultValue": "{\n    \"account\": \"\"\n}"
    }
    ],

我错过了什么或者没有实现该功能吗?

在此先感谢帮助我!

更新:我设法直接从post方法中获取序列化对象,我觉得这是不可能的.这并不能解决自动doc问题,但仍然非常有价值.

解决方法:

Restler 3 RC4昨天发布了自定义类参数功能

阅读http://restler3.luracast.com/param.html#type以获取示例和测试代码

标签:php,swagger,restler
来源: https://codeday.me/bug/20190709/1409930.html