【问题标题】:Mark restler method param as optional in swagger documentation在 swagger 文档中将 restler 方法参数标记为可选
【发布时间】:2015-08-30 01:38:17
【问题描述】:

我正在使用 Restler 框架来编写我的 API,它使用 swagger 来记录事物。当我定义我的方法时,生成的文档有两个问题。一是参数的描述没有大张旗鼓地显示,二是说它们都是必需的。如何在文档中将它们标记为可选?我正在做类似下面的事情,其中​​类别和图片是可选参数。

    /**
     * Create a new News post
     * 
     * Creates a new News post
     *
     * @param string $title The title of the task.
     * @param string $url The URL of the webpage to display.
     * @param string $body The text of the news article.
     * @param int $team_id The sql_ident of the Team this news article relates to.
     * @param string $categories The comma separated list of categories.
     * @param string $picture The URL to the picture to display.
     *
     * @status 201
     *
     * @return array The sql_ident of the new article
     */
    function post($title, $url, $body, $team_id, $categories = '', $picture = '') {

【问题讨论】:

    标签: swagger restler


    【解决方案1】:

    更新:如果您在 RC6 中使用 Explorer 类并且可选参数仍按要求显示,请下载最新更新。我们刚刚发布了一个修复程序!


    你的例子是对的,我们通过在PHP中指定默认值来标记可选参数。这足以将它们记录为可选。如果你想更清楚,你也可以在这些参数的描述中添加(optional)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-19
      • 1970-01-01
      • 2017-06-10
      • 1970-01-01
      相关资源
      最近更新 更多