-
Notifications
You must be signed in to change notification settings - Fork 63
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
Property affoardances compact non-json-schema semantic types (@type) to json-schema type
using the TD 1.1 @context
#2041
Comments
type
using the TD 1.1 @contexttype
using the TD 1.1 @context
Thanks @SunsetFi for the issue. From my initial analysis, this seems to be a bug and the change happened in #1468 . @ethieblin could you comment since the PR came from you? Also tagging @mahdanoura who can help from the TF. |
I did some digging and found out there is a round tripping issue regarding the JSON-LD With the current Context file, when processing the following compact JSON-LD snippet: {
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"id": "scenes::scene-43655d47-d1c5-4f1a-a4ed-64960f513ffa",
"@type": "Thing",
"description": "Scene",
"properties": {
"scenes:scene-name": {
"@type": [
"https://myschema#TitleProperty"
],
"type": "number",
"minLength": 1,
"readOnly": false,
"title": "Name"
}
},
"title": "scenes:scene-43655d47-d1c5-4f1a-a4ed-64960f513ffa"
} The "@type": [
"https://myschema#TitleProperty",
"https://www.w3.org/2019/wot/json-schema#NumberSchema"
] This expansion is incorrect in my opinion, because the JSON-LD On the other hand, when processing the expanded JSON-LD snippet: [
{
"@id": "scenes::scene-43655d47-d1c5-4f1a-a4ed-64960f513ffa",
"@type": [
"https://www.w3.org/2019/wot/td#Thing"
],
"https://www.w3.org/2019/wot/td#description": [
{
"@value": "Scene"
}
],
"https://www.w3.org/2019/wot/td#hasPropertyAffordance": [
{
"http://www.w3.org/1999/02/22-rdf-syntax-ns#type": [
{
"@id": "https://www.w3.org/2019/wot/json-schema#NumberSchema"
}],
"@type": [
"https://myschema#TitleProperty"
]
,
"https://www.w3.org/2019/wot/json-schema#minLength": [
{
"@value": 1
}
],
"https://www.w3.org/2019/wot/json-schema#readOnly": [
{
"@value": false
}
],
"https://www.w3.org/2019/wot/td#name": [
{
"@value": "scenes:scene-name"
}
],
"https://www.w3.org/2019/wot/td#title": [
{
"@value": "Name"
}
]
}
],
"https://www.w3.org/2019/wot/td#title": [
{
"@value": "scenes:scene-43655d47-d1c5-4f1a-a4ed-64960f513ffa"
}
]
}
] The resulting compacted JSON-LD is: {
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"id": "scenes::scene-43655d47-d1c5-4f1a-a4ed-64960f513ffa",
"@type": "Thing",
"td:description": "Scene",
"properties": {
"scenes:scene-name": {
"type": "https://myschema#TitleProperty",
"rdf:type": {
"id": "jsonschema:NumberSchema"
},
"minLength": 1,
"readOnly": false,
"td:title": "Name"
}
},
"td:title": "scenes:scene-43655d47-d1c5-4f1a-a4ed-64960f513ffa"
} Two problems arise here. As identified by @SunsetFi the keyword |
The PR #1468 assigns "type": {
"@id": "@type"
} which means that the JSON Schema Therefore, I think for now we should revert back to the original context which defines type as "@id": "rdf:type",
"@type": "@vocab" |
I am resurrecting an old project based on this standard and porting it to the official TD 1.1 spec. Previously, it was pointing at a working draft copy around 2021.
With the previous spec, I was able to define both the
type
and the@type
properties of the property affordance independently, by reserving@type
for semantic types, and settinghttp://www.w3.org/1999/02/22-rdf-syntax-ns#type
to the json schema property type.Reviewing the changes to TD 1.1, it now appears that the json schema
type
property is mapped to@type
directly withThis makes it impossible to define semantic types with
@type
, as now every value specified on@type
will be compacted to an array attype
.For example, specifying this on a property:
compacts to this:
Which is invalid, as
type
can only be a string, not an array.For a full example, try compacting this with
https://www.w3.org/2022/wot/td/v1.1#
This also contradicts the documentation, where
@type
andtype
are defined independently:https://www.w3.org/TR/2023/REC-wot-thing-description11-20231205/#table-vocabulary-terms-in-dataschema-level
The docs make it clear that
@types
is used for semantic typing, and thattype
is used for the json schema data type.In practical terms, this means I can no longer apply semantic typings to my properties, as having them invade the
type
property causes issues with rendering the UI.Unfortunately, the whole project is set up to pull in expanded json-ld from multiple sources and perform a final compaction operation on it, so I cannot simply ignore the context and emit the json as documented in the spec. The project relies on being able to specify everything in expanded form and have the context correctly compact the data.
Is there a way to form the expanded form of the thing definition that compacts
type
independently from@type
? I believe I can modify the context itself to accomplish this, but would much prefer to keep pointing at the published spec instead of having to fork the definitions.The text was updated successfully, but these errors were encountered: