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

added"@type": "@id" for image and removed imageUrl #453

Closed
wants to merge 1 commit into from

Conversation

yibeichan
Copy link
Contributor

had discussion with @satra and @djarecka on slack about image and imageUrl, we decide

  • adding "@type": "@id" here
    "image": {
    "@id": "schema:image",
    "@type": "@id"
    },
    , otherwise image can't pass the validation
  • removing imageUrl since imageUrl and image are the same now and only image was used in demo-protocol and reproschema-library

we can integrate these changes for the next release

@yibeichan
Copy link
Contributor Author

@satra , i saw your comment on the cookicutter issue, but is related to this PR too
since imageUrl was created for a reason, we need to figure out why things work/don't work.
i provided the background info and problem identified here, you can read problem identified first,

background info

  1. in schema.org, schema:image is defined as the following; it can be either an URL or an ImageObject

    image
    A Schema.org Property
    Thing > Property :: image
    [more...]

    Canonical URL: https://schema.org/image
    Check for open issues.

An image of the item. This can be a URL or a fully described ImageObject.
Values expected to be one of these types

[ImageObject](https://schema.org/ImageObject)
[URL](https://schema.org/URL)

Used on these types

[Thing](https://schema.org/Thing)
  1. in schema.org shacl, image defined as
[ sh:or ( [ sh:node :ValidSchemaImageObject ] [ sh:node :ValidSchemaURL ] ) ;
            sh:path schema1:image ],
  1. in reproschema generic, we have
    "image": {
    "@id": "schema:image"
    },
    "imageUrl": {
    "@id": "schema:image",
    "@type": "@id"
    },

    imageUrl is defined as @id an identifier in schema.org, so
    Values expected to be one of these types
  1. in reproschema shacl, we have
[ sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node reproschema:MediaObjectShape ] ) ;
            sh:path schema:image ]

it means that we expect image to be either IRI or reproschema:MediaObjectShape

here is the definition of reproschema:MediaObjectShape

reproschema:MediaObjectShape a sh:NodeShape ;
sh:closed true ;
sh:ignoredProperties ( rdf:type ) ;
sh:property [ sh:minCount 1 ;
sh:nodeKind sh:IRI ;
sh:path schema:contentUrl ],
[ sh:datatype rdf:langString ;
sh:maxCount 1 ;
sh:path schema:inLanguage ] .

problem identified

"image": "https://picsum.photos/500/400" failed but "imageUrl": "https://picsum.photos/500/400" succeed
why? because https://picsum.photos/500/400 is interpreted as Literal not an IRI, see the error here

ValueError: Validation Report
Conforms: False
Results (1):
Constraint Violation in OrConstraintComponent (http://www.w3.org/ns/shacl#OrConstraintComponent):
	Severity: sh:Violation
	Source Shape: [ sh:or ( [ sh:nodeKind sh:IRI ] [ sh:node reproschema:MediaObjectShape ] ) ; sh:path schema:image ]
	Focus Node: <http://localhost:8000/activities/voiceActivity/items/audio_image_record_item>
	Value Node: Literal("https://picsum.photos/500/400", lang=en)
	Result Path: schema:image
	Message: Node Literal("https://picsum.photos/500/400", lang=en) does not conform to one or more shapes in [ sh:nodeKind sh:IRI ] , [ sh:node reproschema:MediaObjectShape ]

while imageUrl as @id can support text. I tested it as "imageUrl": "some random text for testing" still passed the validation.

so, now we know what the problem is: our URL can't be interpreted as IRI properly, rather, it's treated as literal.

@yibeichan
Copy link
Contributor Author

@djarecka hi, based on our recent updates, what should we do with this PR? merge it or ditch it?

@djarecka
Copy link
Member

i thing we can close it, and I will remove imageUrl from the new context

@djarecka djarecka closed this May 11, 2024
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

Successfully merging this pull request may close these issues.

2 participants