被否决
这一部分正在贬值。 代码基础已移动到 amf 组件 模块。 此模块将在 PR 1 常规文件 合并.
AMF组件用于计算AMF值的共同函数. 这种混合剂可以安全地用于Polymer和LitElement项目以及纯网络组件.
版本兼容性
此版本仅与AMF模式版本2(AMF parser QQ 4.0.0)相通.
用于与上一个模型版本的兼容性 3.x.x 版本的组件.
更新 API 的基础 URI
(仅在使用时适用) _computeUri() 函数)
默认情况下, 组件按定义提供文档 在AMF模型中。 但有时你可能需要替换基础URI aPI里还有别的东西 API 不使用时有用 已定义了基准 URI 属性( 因此, 此组件将相对 路径而不是 URI),或者当您想要管理不同的环境时.
更新基准 URI 值 baseUri 属性.
当组件为终点构建最后的URI时,它做如下工作:
- 若为
baseUri设置它使用这个值作为终点的 URI 基础 - 否则,如果
amf然后它从主模型文档中计算出基准URI值 然后它把基底URI计算出来endpoint'路径属性.
使用 AMF 密钥
混音有 AMF 模型命名空间定义 ns 属性。 使用这个
结构以请求 AMF 密钥( 例如在调用时) _getAmfKey()) (中文(简体) ).
AMF 键可能会随时间而变化. 这样可以更容易地管理密钥
因为组件不需要改变, 只是这种混合.
别这样
const key = this._getAmfKey(this.ns.aml.vocabularies.document + 'encodes');
const key = shape[this.ns.aml.vocabularies.document + 'encodes'];
这样做
const key = this._getAmfKey(this.ns.aml.vocabularies.document.encodes);
const value = model[key];
// acceptable only if AMF model is not compact.
const value = model[this.ns.aml.vocabularies.document.encodes];
安装
npm i @api-components/amf-helper-mixin
使用量
import { LitElement } from 'lit-element';
import { AmfHelperMixin } from '@api-components/amf-helper-mixin/amf-helper-mixin.js';
class AmfHelperImpl extends AmfHelperMixin(LitElement) {
static get properties() {
return {
myProp: { type: String }
};
}
}
发展
git clone https://github.com/@advanced-rest-client/amf-helper-mixin
cd amf-helper-mixin
npm install
运行测试
npm test
部署
创建主分支的 PR 。 一旦主分支有了新的承诺 .github/workflows/deployment.yaml 脚本运行,将公布给GitHub和国家预防机制。 注意, 您需要手动设置新版本的软件包 .