feat: add JSON:API content negotiation support for REST endpoints#148
Open
teethaking wants to merge 1 commit into
Open
feat: add JSON:API content negotiation support for REST endpoints#148teethaking wants to merge 1 commit into
teethaking wants to merge 1 commit into
Conversation
- Create src/middleware/jsonapi.ts middleware for Accept header transformation - Transform responses for transfers, summary, assets, and NFT endpoints - Add comprehensive unit and integration tests - Document JSON:API format in README with examples
|
@teethaking Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Summary
Adds support for
Accept: application/vnd.api+jsoncontent negotiation, allowing clients to request JSON:API-shaped responses from major endpoints — the convention preferred by enterprise integrators — without changing the default response shape for existing consumers.Closes #135
What changed
src/middleware/jsonapi.ts(new)AcceptheaderAccept: application/vnd.api+jsonis present, transforms the standard response payload into a JSON:API-compliant document:dataenvelope withtype,id, andattributesrelationshipskey per the JSON:API specContent-Typetoapplication/vnd.api+jsonapplication/json), the existing response shape is returned unchanged — fully backward compatibleDocumentation
Acceptheader and resulting response shapeHow to verify
Accept: application/vnd.api+jsonand assert the response is JSON:API-shaped (data,type,id,attributes)Acceptheader (orapplication/json) and assert the original response shape is unchangedContent-Type: application/vnd.api+jsonis set on negotiated responsesChecklist
src/middleware/jsonapi.tsimplements content negotiation based onAcceptheaderContent-Typecorrectly set when JSON:API is negotiated