restify / restify/node-restify

Support for application/json-patch+json in bodyParser

Open
#1,987 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
10.7k
Forks
975
Avg merge
1d 6h
Merged PRs (30d)
5

Description

Hello
Currently, Restify’s bodyParser does not parse requests with
Content-Type: application/json-patch+json (RFC 6902).
When sending a PATCH request, req.body is empty, because bodyParser
only supports application/json.

Workaround: I can manually change the header before parsing,
but this is extra boilerplate.

-> Proposal:
Add an optional config in bodyParser, like:

server.use(restify.plugins.bodyParser({
jsonPatch: true
}));

When jsonPatch is true, Restify should treat
application/json-patch+json as normal JSON.

-> Benefits:

  • RFC standard (6902).
  • Very small change (just a header check).
  • Opt-in (does not break compatibility).
  • Improves developer experience for APIs using JSON Patch.

I would like to contribute a PR with this feature.
What do you think?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the bodyParser plugin entry point and trace its Content-Type handling. Implement the opt-in jsonPatch behavior described in the issue, then verify that a PATCH request with application/json-patch+json populates req.body while default behavior remains unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api, backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.