它尚未实施,但我相信 PR 会受到欢迎。
暂时您可以对生成的文档进行后处理,例如通过单衬管管道:
swagger /path/to/project | php -r '$s = json_decode(file_get_contents("php://stdin"),true);array_walk($s["paths"],function(&$p){$p=array_filter($p,function($m){return count(array_intersect(["tag1","tag2"],$m["tags"]))==0;});});file_put_contents("php://stdout",json_encode($s,192));' > public.json
为了可读性而格式化:
$s = json_decode(file_get_contents("php://stdin"), true);
array_walk(
$s["paths"],
function (&$path) {
$path = array_filter(
$path,
function ($method) {
return count(array_intersect(["tag1", "tag2"], $method["tags"])) == 0;
}
);
}
);
file_put_contents("php://stdout", json_encode($s, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
其中tag1 和tag2 是要排除的标签。