CenterForDigitalHumanities / TPEN-services

Services required by TPEN interfaces in order to interact with data
1 stars 0 forks source link

Extend Line web API #57

Open cubap opened 6 months ago

cubap commented 6 months ago

Improve the GET /line/{id} endpoint to return the type of thing expected. Actual connections to the database can be mocked for now.

See #21 for expectations as well as #48 for docs about possible parameters in the request to handle.

Write the failing tests first, then build to suit.

For now, a Line will look like this:

{ 
  "id"          : "#LineId",
  "@context"    : "http://t-pen.org/3/context.json",
  "@type"       : "Annotation",
  "creator"     : "https://store.rerum.io/v1/id/hash",
  "textualBody" : "content of annotation",
  "project"     : "#ProjectId",
  "canvas"      : "https://example.com/canvas.json",
  "layer"       : "#AnnotationCollectionId",
  "viewer"      : "https://static.t-pen.org/#ProjectId/#PageId/#LineId"
  "license"     : "CC-BY"
}

This will be stored in a database that is not set up yet, but you can assume a database controller abstraction with db.getByID() and db.find({property: match}) at a minimum, the return of which will be a JSON that contains the minimum unique Line information.

This endpoint should also provide alternate returns for certain parameters:

These parameters are all mutually exclusive except embed and passing multiple or a nonsense combo ("?view=html&embed=true") is an error.

thehabes commented 6 months ago

Note that Linked Data principles state that the @context property should always be the first property in JSON-LD objects.