【问题标题】:Path parameters optional in Swagger annotationSwagger 注解中可选的路径参数
【发布时间】:2017-04-20 09:16:39
【问题描述】:

我正在使用这个library。我想在我的网址中有一个可选参数

例如我有这条路线

$app->get('/files/{order:\d+}[/{all:0|1|all}]', 'myctroller');

我的注释是

/**
 * @SWG\Get(path="/doc/v1/files/{id_ordine}/{all}",
 *   tags={"GETFILE"},
 *   produces={"application/json"},
 *   @SWG\Parameter(
 *     name="order",
 *     in="path",
 *     type="integer",
 *     required=true,
 *     default="123",
 *   ),
 *   @SWG\Parameter(
 *     name="all",
 *     in="path",
 *     type="string",
 *     enum={"0","1","all"},
 *     default="all",
 *     required=false,
 *   ),
 *   @SWG\Response(response="200", description=xxx"),
 *   @SWG\Response(response="404", xxx")
 * )
 */

使用 Chrome 和 this plugin 我可以用我的文档做 CURL。 如果我选择所有值为 0 的卷曲,我的卷曲就像

http://localhost/doc/v1/files/123/{all}

我想要一个像这样的 CURL

http://localhost/doc/v1/files/123

【问题讨论】:

    标签: php swagger slim swagger-php


    【解决方案1】:

    最近重写了 swagger ui(版本为 v3.0.0),因为您的代码按预期工作。 所以这可能是chrome扩展使用v2.2.8的版本中的一个bug。

    由于swagger ui只有html和js,你可以简单地download a recent version of the swagger-ui并用这个代替扩展名。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-14
      • 2015-01-25
      • 1970-01-01
      • 1970-01-01
      • 2019-04-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多