Skip to content

Allow fallback to use formatter for default format #34

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

Merged
merged 9 commits into from
Nov 18, 2019

Conversation

chrisbloom7
Copy link
Contributor

Fix the fallback formatter issue reported in issue #33

@dblock
Copy link
Member

dblock commented Dec 18, 2014

This definitely needs a spec and a CHANGELOG entry, please.

@dblock
Copy link
Member

dblock commented Mar 1, 2015

Bump @chrisbloom7.

@akicho8
Copy link

akicho8 commented Jul 16, 2015

👍
I was also troubled with the same problem.

@chrisbloom7
Copy link
Contributor Author

@dblock I'll make a note to add tests. Do I just add an entry at the top of the Changelog?

@dblock
Copy link
Member

dblock commented Jul 17, 2015

Yes, please @chrisbloom7.

@dblock
Copy link
Member

dblock commented Jul 6, 2017

Bump @chrisbloom7 ?

@dblock
Copy link
Member

dblock commented Nov 15, 2019

It's still a real problem. You sure you don't want to finish this?

@chrisbloom7
Copy link
Contributor Author

Oh, really? I figured at 5 years old it would have been addressed somewhere along the line. I haven't used Grape in a while, but if you think the fix for this is still relatively the same in the latest version then I can try to find some time to push it through.

@dblock
Copy link
Member

dblock commented Nov 16, 2019

Yes, I think it's still a problem and a worthy fix/addition.

@chrisbloom7 chrisbloom7 reopened this Nov 16, 2019
@chrisbloom7
Copy link
Contributor Author

@dblock tests added and changelog updated

@coveralls
Copy link

coveralls commented Nov 16, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 5e3a24b on chrisbloom7:patch-1 into 359298a on ruby-grape:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 481f4e9 on chrisbloom7:patch-1 into 359298a on ruby-grape:master.

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up!

Please also update the README explaining how the formatter falls back.

Since it's not a backwards compatible change, add an UPGRADING file like https://github.com/ruby-grape/grape/blob/master/UPGRADING.md with a reference to it in README and document how the behavior changed.

Bump the version to 0.5.

Minor test request below.

@chrisbloom7
Copy link
Contributor Author

@dblock I'm digging a little deeper into what env['api.format'] represents and it turns out it's not always going to be the value of default_format. According to https://github.com/ruby-grape/grape#api-formats:

The response format (and thus the automatic serialization) is determined in the following order:

  • Use the file extension, if specified. If the file is .json, choose the JSON format.
  • Use the value of the format parameter in the query string, if specified.
  • Use the format set by the format option, if specified.
  • Attempt to find an acceptable format from the Accept header.
  • Use the default format, if specified by the default_format option.
  • Default to :txt

I think it still makes sense to use env['api.format'] to determine what to fall back to. I'll expand the tests to ensure these are all exercised and update the CHANGELOG and README accordingly to say that it's based on the default response as determined by Grape as opposed to the default_format option specifically.

@chrisbloom7 chrisbloom7 requested a review from dblock November 18, 2019 00:47
@dblock dblock merged commit f808c48 into ruby-grape:master Nov 18, 2019
@dblock
Copy link
Member

dblock commented Nov 18, 2019

Merged, this is perfect.

@chrisbloom7 Want to join the (co)maintainers group and make a release? Shoot me an email to dblock at dblock dot org with your rubygems email if you're into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants