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

Annotation class should allow extra fields for Web Annotation Data Model #223

Open
markpbaggett opened this issue Jan 8, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@markpbaggett
Copy link
Member

The Web Annotation Data Model describes many properties like created, creator, modified, etc. In order to avoid adding all of these to the presentation-validator's json schema, we should probably just allow extras on instances of the class.

Expected behaviour:

If you create an Annotation like so:

body = ResourceItem1(
  type="TextualBody",
  language="de",
  format="text/plain",
  value="Göttinger Marktplatz mit Gänseliesel Brunnen"
)
annotation = Annotation(
  id="https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/canvas-1/annopage-2/anno-1",
  motivation="commenting",
  creator="http://example.org/user1",
  created="2015-01-28T12:00:00Z",
  modified="2015-01-29T09:00:00Z",
  body=body,
  target="https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/canvas-1"
)
print(annotation.json(indent=2))

creator, created, and modified should not be dropped.

Observed behaviour:

The print statement drops the properties:

{
  "@context": "http://iiif.io/api/presentation/3/context.json",
  "id": "https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/canvas-1/annopage-2/anno-1",
  "type": "Annotation",
  "motivation": "commenting",
  "body": {
    "type": "TextualBody",
    "value": "Göttinger Marktplatz mit Gänseliesel Brunnen",
    "format": "text/plain",
    "language": "de"
  },
  "target": "https://iiif.io/api/cookbook/recipe/0266-full-canvas-annotation/canvas-1"
}

Potential bug location(s):

Easiest fix is to add:

class Config:
        extra = Extra.allow

to Annotation.

Any other comments:

Again, it seems burdensome to try to add all these possible properties to the validation schema, so this seems like a good use of Extra.allow.

@markpbaggett markpbaggett added the bug Something isn't working label Jan 8, 2025
@glenrobson
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants