Skip to content

Support for application/json-patch+json in bodyParser #1987

@Edgar0bsj

Description

@Edgar0bsj

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions