Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParamsParser doesn't parse the new JSON API content type #21168

Closed
jfelchner opened this issue Aug 7, 2015 · 4 comments
Closed

ParamsParser doesn't parse the new JSON API content type #21168

jfelchner opened this issue Aug 7, 2015 · 4 comments
Milestone

Comments

@jfelchner
Copy link

I'm not sure if this belongs in the MIME types gem or here so if it belongs elsewhere just let me know.

The new JSON API content type is application/vnd.api+json. Which can be parsed just fine with the current parser in ParamsParser. Unfortunately when the MIME type is parsed it doesn't know to just use the default JSON parser.

@rodzyn
Copy link
Contributor

rodzyn commented Aug 15, 2015

@jfelchner Hey, can you maybe elaborate more on this, maybe preparing some examples with expected output? I was stressing my local app with application/vnd.api+json content type and it seemed to use default JSON parser. I've also added PR with test for this.

@radar
Copy link
Contributor

radar commented Aug 28, 2015

I have a Rails 4.2.3 application which reproduces this issue: https://github.com/radar/rails-21168. If you comment out these lines in config/initializers/mime_types.rb, the test will break:

ActionDispatch::ParamsParser::DEFAULT_PARSERS[Mime::Type.lookup('application/vnd.api+json')] = lambda do |body|
  JSON.parse(body)
end

(There might be a shorter way of writing that first line, but I haven't looked too deeply into it)

So what I think needs to happen is that Rails needs to be configured to automatically JSON.parse the body if the content type is set to application/vnd.api+json. You could probably update your PR to do that, @rodzyn.

@bobintornado
Copy link

Seems #20329 fixed this already. Guess could close the issue.

@sgrif
Copy link
Contributor

sgrif commented Oct 29, 2015

Fixed by #20329

@sgrif sgrif closed this as completed Oct 29, 2015
@rafaelfranca rafaelfranca modified the milestones: 5.0.0 [temp], 5.0.0 Dec 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants