Skip to content

Commit ea17cd1

Browse files
authored
Merge pull request #76 from advanced-rest-client/fix/W-13536254/required-fields
[W-13536254] Required fields
2 parents d95a9ea + 5506083 commit ea17cd1

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@api-components/api-type-document",
33
"description": "A documentation table for type (resource) properties. Works with AMF data model",
4-
"version": "4.2.26",
4+
"version": "4.2.27",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",

src/PropertyShapeDocument.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,13 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
390390
return !!parentTypeName;
391391
}
392392

393+
_toBoolean(value) {
394+
if (typeof value === 'boolean') {
395+
return value
396+
}
397+
return value === 'true'
398+
}
399+
393400
/**
394401
* Computes value for `isRequired` property.
395402
* In AMF model a property is required when `http://www.w3.org/ns/shacl#minCount`
@@ -404,10 +411,11 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
404411
}
405412
shape = this._resolve(shape);
406413
if (this._hasType(shape, this.ns.aml.vocabularies.apiContract.Parameter)) {
407-
return /** @type boolean */ Boolean(this._getValue(
414+
const required = this._getValue(
408415
shape,
409416
this.ns.aml.vocabularies.apiContract.required
410-
));
417+
)
418+
return this._toBoolean(required);
411419
}
412420
const data = this._getValue(shape, this.ns.w3.shacl.minCount);
413421
return data !== undefined && Number(data) !== 0;

0 commit comments

Comments
 (0)