被否决
这一部分正在贬值。 代码基础已移动到 api 文档 模块。 此模块将在 第37号共和国文件 合并.
基于AMF数据模型生成 RAML 注释的元素 .
版本兼容性
此版本仅与AMF模式版本2(AMF parser QQ 4.0.0)相通.
用于与上一个模型版本的兼容性 3.x.x 版本的组件.
使用量
安装
npm install --save @api-components/api-annotation-document
元素需要设置 amf 属性,并带有完整的生成的AMF模型,以正确解决紧凑的JSON模型. 它还要求设置 shape 属性到当前记录的 API 属性(端点、方法、类型(包括类型属性)、安全、安全设置等).
在 html 文件内
<html>
<head>
<script type="module">
import '@api-components/api-annotation-document/api-annotation-document.js';
</script>
</head>
<body>
<api-annotation-document></api-annotation-document>
<script>
{
const model = await getAmfModelSomehow();
const shape = computeCurrentShape(model, someId);
const aad = document.querySelector('api-annotation-document');
aad.amf = model;
aad.shape = shape;
}
</script>
</body>
</html>
在一个LitElement中
import { LitElement, html } from 'lit-element';
import '@api-components/api-annotation-document/api-annotation-document.js';
class SampleElement extends LitElement {
render() {
return html`
<api-annotation-document
.amf="${this.model}"
.shape="${this.shape}"
></api-annotation-document>
`;
}
}
customElements.define('sample-element', SampleElement);
发展
git clone https://github.com/advanced-rest-client/api-annotation-document
cd api-annotation-document
npm install
本地运行演示
npm start
运行测试
npm test