WIP: Fix next and prev links in returned JSON #10
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 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 ifJSON
is the default format. But when using the API if no format is givenHTML
is returned, as ifHTML
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
andprev
links don't have a format specified. The same applies for an impliedoffset
of zero.This means that they return HTML pages not JSON data, as they should.
I am not convinced about the
self
oralternate
links either since they fail to include the offset:The
self
link should make exactly the same call and the twoalternate
s, in my view, should also include theoffset
.