Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jason-fox opened this issue Feb 2, 2024 · 1 comment
Open

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

jason-fox opened this issue Feb 2, 2024 · 1 comment
Assignees
Labels

Comments

@jason-fox
Copy link
Member

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
Copy link
Collaborator

kzangeli commented Feb 2, 2024

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.

@kzangeli kzangeli self-assigned this Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants