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

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

Open
grenik opened this issue Dec 12, 2023 · 1 comment
Open

Comments

@grenik
Copy link

grenik commented Dec 12, 2023

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

@grenik
Copy link
Author

grenik commented Dec 12, 2023

It looks like type-scoped contexts are applied before @nesting, but maybe I missed the part of the specification that states this processing order explicitly.

As for me the spec states the opposite and should behave as I expect:

Semantically, nesting is treated as if the properties and values were declared directly within the containing node object.

And here are even some examples:
image

@grenik grenik changed the title @type-scoped local context is not applied if the @type definition is @nested type-scoped local context is not applied if the @type property is @nested Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant