AsyncDiff是一个比较了两个AsyncAPI文件的库,通过明确指出像突破更改一样的信息来提供差异信息.
这个包裹现在生活在
asyncapi/cli单相 下级packages/diff/从那里释放(同一个 npm 名称)@asyncapi/diff) (中文(简体) ). 比较规则不变.AsyncAPIDiff从软件包条目导出,而两个 输入错误为TypeError有稳定的子类.code。参见规格 :docs/diff/spec.md。 。 。 .
特征
- 获取关于您对 AsyncAPI 文件所做的更改的清晰信息, 如破解、 未破解和未解密的更改 .
- JSON,YAML和Markdown等不同类型的输出.
安装
npm install @asyncapi/diff
使用量
注: 库中没有内置的解析器来解析给定的AsyncAPI文档. 因此,您必须确保它们作为输入提供有效的AsyncAPI文档。 你可以用这个 AsyncAPI 解析器 首先分析并验证 AsyncAPI 文件。 你可以使用其他的工具,但你 必须 确保文档是有效的,并进行调试.
import { diff } from "@asyncapi/diff"; // const { diff } = require('@asyncapi/diff');
const output = diff(firstDocument, secondDocument, {
override: {
// object to override the standard
},
});
标准对象
此库有一个预设的标准,标记为 breaking, (中文(简体) ), non-breaking 或者说 unclassified本标准数据作为对象存储于 standard.ts 文档.
此标准对象的格式解释如下: 这个 文档.
超越标准
要了解压倒性对象的格式,请看 这个 文档.
覆盖对象必须以下列格式传递:
{
[jsonPointer]: {
add: 'breaking' | 'non-breaking' | 'unclassified'
remove: 'breaking' | 'non-breaking' | 'unclassified'
edit: 'breaking' | 'non-breaking' | 'unclassified'
}
}
示例
见 指数 文档以获取此库提供的所有帮助方法.
- 没有任何覆盖
const output = diff(firstDocument, secondDocument);
output.getOutput(); // the whole output data
output.breaking(); // the breaking changes
output.nonBreaking(); // the non-breaking changes
output.unclassified(); // the unclassified changes
- 带有超音速
const output = diff(firstDocument, secondDocument, {
override: {
"/servers/*/protocol": {
add: "non-breaking",
remove: "breaking",
edit: "unclassified",
},
},
});
产出
该库支持以下产出:
- 贾森:
json - 亚马逊:
yaml或者说yml - 标记下 :
markdown或者说md
const jsonOutput = diff(firstDocument, secondDocument, {
outputType: "json",
});
const yamlOutput = diff(firstDocument, secondDocument, {
outputType: "yaml" | "yml",
});
const markdownOutput = diff(firstDocument, secondDocument, {
outputType: "markdown" | "md",
});
降标输出后,您也可以选择更改的子类型为 JSON ()json) 或 YAML( 或 YAML ()yaml 或者说 yml) (中文(简体) ).
const markdownOutput = diff(firstDocument, secondDocument, {
outputType: "markdown" | "md",
markdownSubtype: "json" | "yaml" | "yml",
});
API 密码
检查 指数 文档来查看此库提供的所有 API .
开发
- 密码和测试
- 确保所有测试通过
npm run test - 确保代码格式良好且安全
npm run lint
捐款
帮助我们使这个图书馆更加坚固. 读取 捐款 引导并开始贡献.
贡献者
感谢这些伟大的人emoji 密钥:
阿尤什·库马尔·萨胡 💻 📖 🚧 🤔 👀 ⚠️ |
卢卡斯·戈尔尼茨基 🤔 👀 🚧 |
马西杰·乌尔班奇克 👀 |
乔纳斯·拉戈尼 👀 |
维尼特·沙德奥 👀 |
阿努比哈夫·瓦兹 👀 |
谢文·辛哈 💻 ⚠️ |
德巴吉奥蒂·哈尔德 📖 |
本项目遵循 全部贡献者 规格。 任何捐款都欢迎!
