Skip to content

通过输入所需方法的数组,提取 openapi 部分方法

License

Notifications You must be signed in to change notification settings

36node/swagger-cherry-picker

Repository files navigation

swagger-cherry-picker

通过输入所需方法的数组,提取 openapi 部分方法

支持输入 文件路径 和 url

Quick Start

测试

node exmaple.js

代码使用方法

import swaggerCherryPick from "./index.js";
import fs from "fs";
import yaml from "json2yaml";

const saveFile = (fileName, str) => {
  fs.writeFile(fileName, str, function (error) {
    if (error) {
      console.log("写入失败");
    } else {
      console.log("写入成功");
    }
  });
};

// const file = "./test.yml";
const file = "https://api.youyuan.36node.com/core/uat/openapi.yml";
const newFile = "./new.yml";

const operationIds = ["createPark", "listRepairs", "updateMaintain"];

swaggerCherryPick(file, newFile, operationIds).then((ret) => {
  saveFile("./new.json", JSON.stringify(ret, null, 2));
  saveFile("./new.yaml", yaml.stringify(ret));
});

About

通过输入所需方法的数组,提取 openapi 部分方法

Resources

License

Stars

Watchers

Forks

Packages

No packages published