它尚未实施,但我相信公关将受到欢迎。
暂时您可以对生成的文档进行后期处理,例如,管道直通其单衬:
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
是标签排除。