Skip to content

Commit 5fdf5b3

Browse files
authored
Merge pull request #60 from bewee/bewee/patch-3
Add enum option to properties
2 parents 0589d36 + ef64d85 commit 5fdf5b3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

manifest.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@
128128
"description": "Property values must be a multiple of this number. Only relevant for numeric properties.",
129129
"type": "number"
130130
},
131+
"enum": {
132+
"description": "Property values must be one of these options. Only relevant for string properties.",
133+
"type": "array",
134+
"items": {
135+
"type": "string"
136+
}
137+
},
131138
"readOnly": {
132139
"description": "Whether or not this property is read-only.",
133140
"type": "boolean"

virtual-things-adapter.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,6 +1551,14 @@ class VirtualThingsAdapter extends Adapter {
15511551
}
15521552
}
15531553

1554+
if (
1555+
property.type !== 'string' ||
1556+
!Array.isArray(property.enum) ||
1557+
!property.enum.length
1558+
) {
1559+
delete property.enum;
1560+
}
1561+
15541562
switch (property.type) {
15551563
case 'integer':
15561564
case 'number':
@@ -1619,6 +1627,10 @@ class VirtualThingsAdapter extends Adapter {
16191627
prop.metadata.multipleOf = property.multipleOf;
16201628
}
16211629

1630+
if (property.hasOwnProperty('enum')) {
1631+
prop.metadata.enum = property.enum;
1632+
}
1633+
16221634
if (property.hasOwnProperty('readOnly')) {
16231635
prop.metadata.readOnly = property.readOnly;
16241636
}

0 commit comments

Comments
 (0)