diff --git a/CHANGES_NEXT_RELEASE b/CHANGES_NEXT_RELEASE index cf7c7e0529..dc2f033b73 100644 --- a/CHANGES_NEXT_RELEASE +++ b/CHANGES_NEXT_RELEASE @@ -3,6 +3,7 @@ #1708: Reloaded hosted contexts were not persisted in mongo, only the context cache #XXXX: Using "VocabProperty" and not "VocabularyProperty" (old name still accepted as input) #XXXX: Array reduction for LanguageProperty languageMap values + #XXXX: Array reduction for VocabProperty vocab values, for normalized mode ## New Features: #1707: Support for local=true in the type discovery endpoints (GET /ngsi-ld/v1/types[/{typeName}] diff --git a/src/lib/orionld/payloadCheck/pCheckAttribute.cpp b/src/lib/orionld/payloadCheck/pCheckAttribute.cpp index 368acfb440..aab027a0c8 100644 --- a/src/lib/orionld/payloadCheck/pCheckAttribute.cpp +++ b/src/lib/orionld/payloadCheck/pCheckAttribute.cpp @@ -1127,8 +1127,13 @@ static bool pCheckAttributeObject else LM_W(("No languageMap field found!")); } - - if (attributeType == NoAttributeType) + else if (attributeType == VocabularyProperty) + { + KjNode* vocabP = kjLookup(attrP, "vocab"); + if (vocabP != NULL) + arrayReduce(vocabP); + } + else if (attributeType == NoAttributeType) { if (isGeoJsonValue(attrP)) { diff --git a/test/functionalTest/cases/0000_ngsild/ngsild_vocab-property.test b/test/functionalTest/cases/0000_ngsild/ngsild_vocab-property.test index d1826fa539..7ca7d6100b 100644 --- a/test/functionalTest/cases/0000_ngsild/ngsild_vocab-property.test +++ b/test/functionalTest/cases/0000_ngsild/ngsild_vocab-property.test @@ -50,6 +50,9 @@ accumulatorStart --pretty-print # 11. Query entities with q=V1==abc&expandValues=V1,V2 => see urn:E1 # 12. Query entities with q=V2==id&expandValues=V1,V2 => see urn:E2 # +# 13. Create an entity urn:E4, type T, with a VocabProperty V4 whose vocab is an array with a single element - for array reduction +# 14. GET urn:E4 in normalized format, see V4 with an array-recuced 'vocab' +# echo '01. Create a subscription on entity type T' echo '==========================================' @@ -194,6 +197,25 @@ echo echo +echo "13. Create an entity urn:E4, type T, with a VocabProperty V4 whose vocab is an array with a single element - for array reduction" +echo "================================================================================================================================" +payload='{ + "id": "urn:E4", + "type": "T", + "V4": { "type": "VocabProperty", "vocab": [ "test" ] } +}' +orionCurl --url /ngsi-ld/v1/entities --payload "$payload" +echo +echo + + +echo "14. GET urn:E4 in normalized format, see V4 with an array-recuced 'vocab'" +echo "=========================================================================" +orionCurl --url /ngsi-ld/v1/entities/urn:E4 +echo +echo + + --REGEXPECT-- 01. Create a subscription on entity type T ==========================================