Issue 248 patch - Update JMESPaths #256
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the JMESPath constants for both IIIF Presentation v2 and v3 to fix some potential issues.
Presentation v2:
Problem: Non-Image services could be picked up by the selector.
Fix: Add a filter clause to make sure the
@context
block of the service is for an Image API version. The reason for using this field is per Presentation 2.1.1 section 5.4: "A reference to the Image API context document MUST be included", so on a valid Manifest it will be present.Playgrounds:
Presentation v3:
Problem 1: Current selector only works if all services are v3 (i.e with
id
andtype
). Having even a single v2 service (with@type
) causes the whole selector to fail on thecontains
conditional and return a singlenull
for the entire manifest (not just the one block).Problem 2: Assuming above fixed, current selector only returns
id
for the service, meaning it misses v2 services with@id
.Fix 1: Push both
type
and@type
into a hash, and use thenot_null
function to select the one that actually exists, and then assign it totype
, then use this for the conditional selection of only Image services.Fix 2: Repeat the same push-to-hash/
not_null
trick withid
and@id
, ensuring thatid
will then have the value from whichever one exists.Playgrounds: (n.b. each of these has a third canvas which should never get a
service_id
as it only contains a Search service)null
when one v2 service exists: https://play.jmespath.org/?u=07998489-58d0-47cb-b4ba-5b7dd5278431@
is present in input keys or not: https://play.jmespath.org/?u=b0d17ada-8b30-4f8f-a2cd-9f8296b90b78