diff --git a/src/lib/orionld/dbModel/dbModelToApiAttribute.cpp b/src/lib/orionld/dbModel/dbModelToApiAttribute.cpp index ae748c2302..a316374629 100644 --- a/src/lib/orionld/dbModel/dbModelToApiAttribute.cpp +++ b/src/lib/orionld/dbModel/dbModelToApiAttribute.cpp @@ -378,18 +378,25 @@ KjNode* dbModelToApiAttribute2(KjNode* dbAttrP, KjNode* datasetP, bool sysAttrs, } else if (strcmp(attrTypeNodeP->value.s, "VocabularyProperty") == 0) { - attrP = kjLookup(dbAttrP, "value"); + KjNode* valueP = kjLookup(dbAttrP, "value"); - if (attrP->type == KjString) - attrP->value.s = orionldContextItemAliasLookup(orionldState.contextP, attrP->value.s, NULL, NULL); - else if (attrP->type == KjArray) + if (valueP->type == KjString) + valueP->value.s = orionldContextItemAliasLookup(orionldState.contextP, valueP->value.s, NULL, NULL); + else if (valueP->type == KjArray) { - for (KjNode* wordP = attrP->value.firstChildP; wordP != NULL; wordP = wordP->next) + for (KjNode* wordP = valueP->value.firstChildP; wordP != NULL; wordP = wordP->next) { if (wordP->type == KjString) wordP->value.s = orionldContextItemAliasLookup(orionldState.contextP, wordP->value.s, NULL, NULL); } } + + // Remove everything except the value, and change its name to "vocab" + dbAttrP->value.firstChildP = valueP; + dbAttrP->lastChild = valueP; + valueP->next = NULL; + valueP->name = (char*) "vocab"; + attrP = dbAttrP; } else { diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_vocab-property.test b/test/functionalTest/cases/0000_ngsild/ngsild_vocab-property.test index 53ec34d274..8529990a0e 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_vocab-property.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_vocab-property.test @@ -41,7 +41,7 @@ accumulatorStart --pretty-print # 05b. See urn:E2 in the DB - see [ "vocab", "id" ] expanded # 06. Dump/Reset accumulator, see urn:E1+V1 and urn:E2+V2 # -# 07. GET urn:E1 in simplified format +# 07. GET urn:E2 in simplified format # echo '01. Create a subscription on entity type T' @@ -127,7 +127,7 @@ echo echo -echo "07. GET urn:E1 in simplified format" +echo "07. GET urn:E2 in simplified format" echo "===================================" orionCurl --url /ngsi-ld/v1/entities/urn:E2?options=simplified echo @@ -323,19 +323,21 @@ Ngsild-Attribute-Format: Normalized ======================================= -07. GET urn:E1 in simplified format +07. GET urn:E2 in simplified format =================================== HTTP/1.1 200 OK -Content-Length: 46 +Content-Length: 56 Content-Type: application/json Date: REGEX(.*) Link: