你好Restler朋友,
我目前正在尝试切换到Restler作为我们的主要Rest-Framework.真正推动我决定的是宽松的合规性.我发现为一个长大的系统提供一个很好的自动生成文档是非常重要的.
当然,您可以从“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.
account (required): add @param {type} $account {comment} to describe here",
"paramType": "body",
"required": true,
"allowMultiple": false,
"dataType": "Object",
"defaultValue": "{\n \"account\": \"\"\n}"
}
],
我错过了什么或者没有实现该功能吗?
在此先感谢帮助我!
更新:我设法直接从post方法中获取序列化对象,我觉得这是不可能的.这并不能解决自动doc问题,但仍然非常有价值.
解决方法:
Restler 3 RC4昨天发布了自定义类参数功能
标签:php,swagger,restler
来源: https://codeday.me/bug/20190709/1409930.html