Skip to content

Commit 91fc538

Browse files
authored
Merge pull request #7 from advanced-rest-client/fix/W-13536254/required-fields
[W-13536254] Required fields
2 parents e5beda2 + a25028d commit 91fc538

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@api-components/api-forms",
33
"description": "A library containing helper classes to compute API data from the AMF web API model.",
4-
"version": "0.2.5",
4+
"version": "0.2.6",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",
@@ -20,10 +20,10 @@
2020
],
2121
"repository": {
2222
"type": "git",
23-
"url": "git://github.com/advanced-rest-client/arc-headers.git"
23+
"url": "git://github.com/advanced-rest-client/api-forms.git"
2424
},
2525
"bugs": {
26-
"url": "https://github.com/advanced-rest-client/arc-headers/issues"
26+
"url": "https://github.com/advanced-rest-client/api-forms/issues"
2727
},
2828
"dependencies": {
2929
"@advanced-rest-client/arc-icons": "^3.3.3",

src/ApiViewModel.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,13 @@ export class ApiViewModel extends AmfHelperMixin(Object) {
266266
return result;
267267
}
268268

269+
_toBoolean(value) {
270+
if (typeof value === 'boolean') {
271+
return value
272+
}
273+
return value === 'true'
274+
}
275+
269276
/**
270277
* Creates a UI model item from AMF json/ld model for a parameter.
271278
* @param {any} amfItem AMF model with schema for
@@ -276,7 +283,7 @@ export class ApiViewModel extends AmfHelperMixin(Object) {
276283
amfItem = this._resolve(amfItem);
277284
const binding = /** @type string */ (this._getValue(amfItem, this.ns.aml.vocabularies.apiContract.binding))
278285
const name = this._computeFormName(amfItem);
279-
const required = /** @type boolean */ (this._getValue(amfItem, this.ns.aml.vocabularies.apiContract.required))
286+
const required = this._toBoolean(this._getValue(amfItem, this.ns.aml.vocabularies.apiContract.required))
280287
const schemaItem = /** @type AmfFormItemSchema */ ({
281288
required,
282289
});
@@ -726,7 +733,7 @@ export class ApiViewModel extends AmfHelperMixin(Object) {
726733
_computeRequiredPropertyShape(model) {
727734
const key = this.ns.w3.shacl.minCount;
728735
const result = this._getValue(model, key);
729-
return result === 1;
736+
return Number(result) === 1;
730737
}
731738

732739
/**

0 commit comments

Comments
 (0)