swagger-php 具有来自相同代码的不同文档 [英] swagger-php having different documentations from the same code

查看:47
本文介绍了swagger-php 具有来自相同代码的不同文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用 slim 框架和 swagger-php 来动态生成 swagger 文档.我们现在在 API 中有一些不应公开记录的特殊方法.(/现在文档)有什么方法可以让我获得第二个文档 url (/doc2),我可以在其中记录秘密方法和参数吗?(无需手工制作文档,只需使用 php 代码中的注释).谢谢.

We are using slim framework and swagger-php to dynamically generate the swagger documentation. We now have some special methods in the API that should not be publicly documentated. (/doc now) Is there any way I can have a second documentation url (/doc2) where I can get the secret methods and params documentated? (without having to make the documentation by hand, just using the annotations in the php code). Thanks.

推荐答案

根据最新版本的 swagger-php,您可以指定在构建文档时排除扫描的文件和/或目录列表.

As per the latest version of swagger-php you can indicate a list of files and/or directories to exclude from scanning when building the documentation.

查看扫描功能的docblockgithub 了解详情.

See the scan function's docblock on github for details.

解决您的问题的方法是将公共方法和私有方法分离到不同的文件中.然后创建两个文档生成方法/函数,每个方法/函数都排除对方的文件.

A solution to your problem is to separate the public and private methods into different files. Then create two documentation generation methods/functions each excluding the other's files.

示例:

$privateOptions = array(
    'exclude' => array('app/api/public')
);
$privateDoc = Swagger\scan("app/", $privateOptions);
...
$publicOptions = array(
    'exclude' => array('app/api/private')
);
$publicDoc = Swagger\scan("app/", $publicOptions);

注意:此示例是指示性的,未经测试,您也可以排除文件名.

Note: This example is indicative and not tested, you can also exclude filenames.

这篇关于swagger-php 具有来自相同代码的不同文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆