Skip to content

type-scoped local context is not applied if the @type property is @nested #831

Open
@grenik

Description

@grenik

The following example works as expected (playground permalink)

{
  "@context": {
    "type": "@type",
    "name": "http://example.com/vocab#top-level-name",
    "MyType": {
      "@id": "http://example.com/vocab#MyTypeURI",
      "@context": {
        "name": "http://example.com/vocab#typed-name"
      }
    }
  },
  "type": "MyType",
  "name": "top-level-name"
}

is expanded to:

[
  {
    "http://example.com/vocab#typed-name": [
      {
        "@value": "top-level-name"
      }
    ],
    "@type": [
      "http://example.com/vocab#MyTypeURI"
    ]
  }
]

so the URI for name is taken from the type-scoped context and is ...typed-name

Error:

Once I @nest the @type definition in __metadata wrapper object, the typed-context is not applied anymore and thus the name is not mapped to an IRI, even though @type is extracted:

Example 1:

Playground permalinks: with and without @nest for @type.

{
  "@context": {
    "type": "@type",
+   "__metadata": "@nest",
    "MyType": {
      "@id": "http://example.com/vocab#MyTypeURI",
      "@context": {
        "name": "http://example.com/vocab#typed-name"
      }
    }
  },
  "name": "top-level-name",
+ "__metadata": {
    "type": "MyType"
+ }
}

results in typed context not being applied and the name being not mapped anymore:

[
  {
-   "http://example.com/vocab#typed-name": [
-     {
-       "@value": "top-level-name"
-     }
-   ],
    "@type": [
      "http://example.com/vocab#MyTypeURI"
    ]
  }
]

same if I specify @nest for the @type as well:

{
  "@context": {
    "type": {
+     "@nest": "__metadata",
      "@id": "@type"
    },
+   "__metadata": "@nest",
    "MyType": {
      "@id": "http://example.com/vocab#MyTypeURI",
      "@context": {
        "name": "http://example.com/vocab#typed-name"
      }
    }
  },
  "name": "top-level-name",
+ "__metadata": {
    "type": "MyType"
+ }
}

I expect the same result as in the original example on top, with name being mapped to http://example.com/vocab#typed-name

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions