Skip to content

Context serialization created using JSONLD_FRAME_FLAT setting @set for @type results in an invalid Context #337

@dnx2710

Description

@dnx2710

Given a context like:

"@context": {
    "@vocab": "https://example.org",
    "@type": {
      "@container": "@set"
    }
}

When using the serialization for framing, the term's definition value for @id is used and added to the context resulting in:

"@context": {
    "@vocab": "https://example.org",
    "@type": {
      "@id": "type"
      "@container": "@set"
    }
}

This goes against the de-serialization rules:

if (JsonLdUtils.isKeyword(term)
&& !(options.getAllowContainerSetOnType() && JsonLdConsts.TYPE.equals(term)
&& !(context.get(term)).toString().contains(JsonLdConsts.ID))) {
throw new JsonLdError(Error.KEYWORD_REDEFINITION, term);
}

The type's @id definition was added in change: 673dac2 and seems like it was tested with compact serialization.

Serialization references:

if (JsonLdConsts.TYPE.equals(term)) {
definition.put(JsonLdConsts.ID, "type");
}

final String cid = this.compactIri((String) definition.get(JsonLdConsts.ID));
final Boolean reverseProperty = Boolean.TRUE
.equals(definition.get(JsonLdConsts.REVERSE));
if (!(term.equals(cid) && !reverseProperty)) {
defn.put(reverseProperty ? JsonLdConsts.REVERSE : JsonLdConsts.ID, cid);
}

final Map<String, Object> rval = activeCtx.serialize();

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