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

WIP: Fix next and prev links in returned JSON #10

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

ximenesuk
Copy link
Collaborator

This fixes the next/prev issue outlined below and the modified tests pass. But I'm not 100% I understand what is going on. In the tests the mock requests are made without a format type, but JSON is returned. As if JSON is the default format. But when using the API if no format is given HTML is returned, as if HTML is the default. I have not managed to track through the code to see why there is this mismatch.

I have modified the mocks to ask for JSON and the code to use the format in the next/prev links. So It works, but whether it is correct to what they think should be happening is another thing!

I will leave this PR as WIP.

Background

If you make a call to our current ogcapi asking for JSON data with and offset and limit:

https://ogcapi.bgs.ac.uk/collections/recentearthquakes/items?f=json&offset=100&limit=100

And scroll down to the links at the bottom, the next and prev links don't have a format specified. The same applies for an implied offset of zero.

        {
            "type": "application/geo+json",
            "rel": "prev",
            "title": "items (prev)",
            "href": "https://ogcapi.bgs.ac.uk/collections/recentearthquakes/items?offset=0&limit=100"
        },
        {
            "type": "application/geo+json",
            "rel": "next",
            "title": "items (next)",
            "href": "https://ogcapi.bgs.ac.uk/collections/recentearthquakes/items?offset=200&limit=100"
        },

This means that they return HTML pages not JSON data, as they should.

I am not convinced about the self or alternate links either since they fail to include the offset:

        {
            "type": "application/geo+json",
            "rel": "self",
            "title": "This document as GeoJSON",
            "href": "https://ogcapi.bgs.ac.uk/collections/recentearthquakes/items?f=json&limit=100"
        },
        {
            "rel": "alternate",
            "type": "application/ld+json",
            "title": "This document as RDF (JSON-LD)",
            "href": "https://ogcapi.bgs.ac.uk/collections/recentearthquakes/items?f=jsonld&limit=100"
        },
        {
            "type": "text/html",
            "rel": "alternate",
            "title": "This document as HTML",
            "href": "https://ogcapi.bgs.ac.uk/collections/recentearthquakes/items?f=html&limit=100"
        },

The self link should make exactly the same call and the two alternates, in my view, should also include the offset.

@KoalaGeo
Copy link
Collaborator

KoalaGeo commented Oct 6, 2022

FYI don't PR to master we've got out of sync trying to get the container build to work

@ximenesuk
Copy link
Collaborator Author

FYI don't PR to master we've got out of sync trying to get the container build to work

It is a WIP for John to view. It can be rebased. And without being told in advance where to open a PR I have little choice!

@KoalaGeo KoalaGeo changed the base branch from master to main May 9, 2023 10:27
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.

3 participants