Skip to content

Support different incoming to outgoing content-type #1697

Open
@stevelacey

Description

@stevelacey

I am attempting to upgrade to v1 and have been banging my head against problems caused by #1589

We do some JSON Merge Patch – prior to #1589 that was as simple as:

if request.content_type == 'application/merge-patch+json'
  # do something different
end

Now I have to do some of this to dodge 406's

content_type :json_merge_patch, 'application/merge-patch+json'
format :json_merge_patch
formatter :json_merge_patch, Grape::Formatter::ActiveModelSerializers
error_formatter :json_merge_patch, ACME::JsonErrorFormatter
parser :json_merge_patch, Grape::Parser::Json

And this works, but now the API serves out Content-Type: application/merge-patch+json – but it should still be application/json, the request was partial but the response is full.

I expect I need to adjust the formatter to do this... but given ours is ActiveModelSerializers it's pretty abstract and I am not sure where JSON comes into it.

Is there really the need for all of this boilerplate to do this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions