Pin the problem+json error/negotiation contract#52
Merged
Conversation
Add two ErrorContractTest cases for Accept: application/problem+json: an unauthenticated request is served as RFC 7807 problem+json (401, unprefixed title/detail/status/type), while requesting a resource item in problem+json yields 406 Not Acceptable (the resources only produce ld+json) with a problem+json error body. Closes the last untested corner of the error contract and documents that problem+json is not a resource representation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #52 +/- ##
==========================================
Coverage 72.99% 72.99%
Complexity 232 232
==========================================
Files 29 29
Lines 648 648
==========================================
Hits 473 473
Misses 175 175
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes the last untested corner of the error contract: what the API does when a client asks for
application/problem+json.Changes
Two new
ErrorContractTestcases (verified against the running 4.3 API):GET /api/v2/events(unauthenticated) withAccept: application/problem+json→ 401,content-type: application/problem+json, RFC 7807 fields (title,detail,status,type). The 401 short-circuits before resource negotiation, so it is served in the requested media type.GET /api/v2/events/{id}withAccept: application/problem+json→ 406 Not Acceptable (the resources only produceld+json), and the 406 body is itself a problem+json error.Why
The regenerated 4.3 spec documents
application/problem+json/application/jsonmedia types on error responses, but nothing tested whether the API actually serves them. This pins the real behaviour: problem+json is available for errors that precede resource negotiation (401), but is not a resource representation — asking for it on a resource yields 406, not the resource and not a 404. Consumers must read resources asld+json. Tests only.