FIWARE / context.Orion-LD

Context Broker and CEF building block for context data management which supports both the NGSI-LD and the NGSI-v2 APIs
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf
GNU Affero General Public License v3.0
49 stars 40 forks source link

The attributes of a JSON object `value` should undergo expansion. #1546

Open jason-fox opened 5 months ago

jason-fox commented 5 months ago

Create an Entity with a Property whose value is a JSON Object.

curl -iX POST \
  http://localhost:1026/ngsi-ld/v1/entities \
  -H 'Content-Type: application/ld+json' \
  -d '{
    "id": "urn:ngsi-ld:Building:store001",
    "type": "Building",
    "address": {
        "type": "Property",
        "value": {
            "streetAddress": "Bornholmer Straße 65",
            "addressRegion": "Berlin",
            "addressLocality": "Prenzlauer Berg",
            "postalCode": "10439"
        }
    },
    "@context": "https://raw.githubusercontent.com/FIWARE/tutorials.Relationships-Linked-Data/master/data-models/user-context.jsonld"
}

The supplied User @context includes subattribute term mappings as shown:

{
   "@context" : {
        "address": "schema:address",
        "addressCountry": "schema:addressCountry",
        "addressLocality": "schema:addressLocality",
        "addressRegion": "schema:addressRegion"
     }
}

Then receive the entities by type as shown without supplying a User @context:

curl -G -X GET \  
  'http://localhost:1026/ngsi-ld/v1/entities' \
  -H 'Accept: application/ld+json' \
  -d 'type=https%3A%2F%2Furi.fiware.org%2Fns%2Fdata-models%23Building' \
  -d 'options=keyValues'

Orion returns:

[ {
  "id" : "urn:ngsi-ld:Building:store001",
  "https://schema.org/address" : {
    "addressLocality" : "Prenzlauer Berg",
    "addressRegion" : "Berlin",
    "postalCode" : "10439",
    "streetAddress" : "Bornholmer Straße 65"
  },
  "@context" : [ "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld" ]
} ]

Since address.value is just a JSON-LD @value, the attributes of the object should undergo expansion. The expected response is:

[ {
  "id" : "urn:ngsi-ld:Building:store001",
  "https://schema.org/address" : {
    "https://schema.org/addressLocality" : "Prenzlauer Berg",
    "https://schema.org/addressRegion" : "Berlin",
    "https://schema.org/postalCode" : "10439",
    "https://schema.org/streetAddress" : "Bornholmer Straße 65"
  },
  "@context" : [ "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context-v1.6.jsonld" ]
} ]
kzangeli commented 5 months ago

Yeah, well aware. Misunderstanding back in 2018. For Orion-LD, we need to work out an approach on how to fix this.

IMO, the value of "value" belongs to the user and thus is sacred and should never ever be modified in any way. However, unfortunately, the API spec of NGSI-LD states otherwise and yes, this is an important bug (undetected by external users since ... always - note that Jason is a colleague of mine in the FIWARE Foundation :() and we need to find a good way of expanding those attribute values, via a DB adaption script, or something similar.