Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@api-components/api-forms",
"description": "A library containing helper classes to compute API data from the AMF web API model.",
"version": "0.2.5",
"version": "0.2.6",
"license": "Apache-2.0",
"main": "index.js",
"module": "index.js",
Expand All @@ -20,10 +20,10 @@
],
"repository": {
"type": "git",
"url": "git://github.com/advanced-rest-client/arc-headers.git"
"url": "git://github.com/advanced-rest-client/api-forms.git"
},
"bugs": {
"url": "https://github.com/advanced-rest-client/arc-headers/issues"
"url": "https://github.com/advanced-rest-client/api-forms/issues"
},
"dependencies": {
"@advanced-rest-client/arc-icons": "^3.3.3",
Expand Down
11 changes: 9 additions & 2 deletions src/ApiViewModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,13 @@ export class ApiViewModel extends AmfHelperMixin(Object) {
return result;
}

_toBoolean(value) {
if (typeof value === 'boolean') {
return value
}
return value === 'true'
}

/**
* Creates a UI model item from AMF json/ld model for a parameter.
* @param {any} amfItem AMF model with schema for
Expand All @@ -276,7 +283,7 @@ export class ApiViewModel extends AmfHelperMixin(Object) {
amfItem = this._resolve(amfItem);
const binding = /** @type string */ (this._getValue(amfItem, this.ns.aml.vocabularies.apiContract.binding))
const name = this._computeFormName(amfItem);
const required = /** @type boolean */ (this._getValue(amfItem, this.ns.aml.vocabularies.apiContract.required))
const required = this._toBoolean(this._getValue(amfItem, this.ns.aml.vocabularies.apiContract.required))
const schemaItem = /** @type AmfFormItemSchema */ ({
required,
});
Expand Down Expand Up @@ -726,7 +733,7 @@ export class ApiViewModel extends AmfHelperMixin(Object) {
_computeRequiredPropertyShape(model) {
const key = this.ns.w3.shacl.minCount;
const result = this._getValue(model, key);
return result === 1;
return Number(result) === 1;
}

/**
Expand Down