Add missing request specs for /api/v1/tags
endpoint
#23146
Closed
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.
For discussion.
This relates to both #20572 and #22378 (comment). I was kicking the tires on swapping out JSON serializers to improve API responsiveness, and was somewhat surprised to discover that there were no API request specs. The API is tested in some controller specs, but those specs are not exhaustive. So, I decided to pick a small endpoint and completely cover the behavior of it.
Given the number of connected clients and the API contract, I believe it's important to have request specs as a source of truth: it proves behavior, documents how the API responds in various circumstances, and prevents accidental breakage (critical in the case of testing out different serialization strategies). This is the tip of the iceberg - I believe the entire API should be covered in these kids of specs.
This PR adds a JSON-Schema specification for Tag and the nested history object that I've called
TrendHistory
, and validates that the API responses match the schema.This PR also introduces some failing tests worth additional discussion. When fleshing the specs out, I expected that the
following
flag in the JSON body would be associated with theread:follows
scope, but that is apparently not the case. The/api/v1/tags
endpoint always returns hashtag following information whenever there is an authenticated user, regardless of what scope the user has. I have a separate PR to tackle this, but I'm not sure that my expectations are indeed the actual expected behavior or not. I did raise this issue privately, and was given the green light to publicly discuss the behavior of it.So, a few questions to help spark discussion:
following
flag? Should it move behind an oauth scope? If so, should it re-useread:follows
, or should a new one be made, such asread:tag_follows
? I do have a PR I can submit that omits the flag from the response unless the user hasread:follows
scope granted, but I'm not sure that's desirable.