📅 You're Invited: Meet the Socket team at RSAC (April 28 – May 1).RSVP
Socket
Sign inDemoInstall
Socket

@api-components/api-example-generator

Package Overview
Dependencies
Maintainers
4
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@api-components/api-example-generator - npm Package Compare versions

Comparing version

to
4.4.15

2

package.json
{
"name": "@api-components/api-example-generator",
"description": "Examples generator from AMF model",
"version": "4.4.14",
"version": "4.4.15",
"license": "Apache-2.0",

@@ -6,0 +6,0 @@ "main": "index.js",

@@ -1,3 +0,9 @@

# ExampleGenerator
# DEPRECATED
This component is being deprecated. The code base has been moved to [api-documentation](https://github.com/advanced-rest-client/api-documentation) module. This module will be archived when [PR 37](https://github.com/advanced-rest-client/api-documentation/pull/37) is merged.
The tests and the logic were migrated to the `@api-components/api-schema` module.
-----
Generates examples from the AMF model.

@@ -4,0 +10,0 @@

@@ -1256,2 +1256,5 @@ /* eslint-disable class-methods-use-this */

}
if (this._hasProperty(range, this.ns.w3.shacl.and)) {
return this._computeJsonAndValue(range, typeName);
}
if (this._hasType(range, this.ns.w3.shacl.NodeShape)) {

@@ -1416,2 +1419,36 @@ return this._computeJsonObjectValue(range);

_computeJsonAndValue(range, typeName) {
const key = this._getAmfKey(this.ns.w3.shacl.and);
const list = this._ensureArray(range[key]);
if (!list) {
return undefined;
}
const pKey = this._getAmfKey(this.ns.w3.shacl.property);
const examples = [];
for (let i = 0, len = list.length; i < len; i++) {
let item = list[i];
if (Array.isArray(item)) {
item = item[0];
}
this._resolve(item);
if (typeName) {
const name = this._getValue(item, this.ns.w3.shacl.name);
if (typeName !== name) {
continue;
}
}
if (this._hasType(item, this.ns.w3.shacl.NodeShape)) {
item = this._resolve(item);
const data = this._ensureArray(item[pKey]);
if (data) {
const example = this._jsonExampleFromProperties(data);
if (example && typeof example === 'object') {
examples.push(example);
}
}
}
}
return examples.reduce((acc, value) => ({...acc, ...value}), {});
}
/**

@@ -1418,0 +1455,0 @@ * Computes JSON object as an example from a range that is an object.