-
Notifications
You must be signed in to change notification settings - Fork 365
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
JSON Content-Type matcher is more inclusive #242
JSON Content-Type matcher is more inclusive #242
Conversation
@oestrich - this modifies some of your code. I realized browsing other pull requests, there is another one, trying to solve the same problem by @AlexandrZ |
@galiat I don't think it makes sense to hardcode this here, there are infinite types of vendor specific content types. Would prefer if this was a configurable array w/ the default value of |
@jakehow I'm glad you brought that up. I was considering the same thing, but wasn't sure the best way to set up the configuration.
Are there other options? What do you think? |
I definitely like the configuration approach more, @jakehow beat me to it! I'd mirror post body format, keep response/request linked. |
b9ef8bd
to
53bbd65
Compare
@oestrich & @jakehow I can push up a subsequent PR so that users can specify :json or :xml along with a proc. What do you think about the default value? If you are ok with not formatting based on |
@galiat IMO json == application/json If you are using a specific subset vendor content type it should have a name other than json. Maybe |
@jakehow We might be misunderstanding each other. Are the symbols ( |
@galiat sorry, did not notice code changed... it looks good to me, I misunderstood your comment. I think we should keep the default behavior to preserve backwards compatibility, it could be expanded to include other standard content types if necessary. The config option should allow anyone using a non-standard type like JSON-API the flexibility they need. You probably always want the proc to get the |
@jakehow is there anything left that I should do before merge? |
@@ -138,7 +138,12 @@ RspecApiDocumentation.configure do |config| | |||
|
|||
# Change how the post body is formatted by default, you can still override by `raw_post` | |||
# Can be :json, :xml, or a proc that will be passed the params | |||
config.post_body_formatter = Proc.new { |params| params } | |||
config.response_body_formatter = Proc.new { |params| params } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be flipped?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops - 😳 Yeap, I'll fix this.
edit: fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…r to the post_body_formatter configuration. Maintains backwards compatibility with pretty formatting content-types of `application/json` the JSON API spec uses `application/vnd.api+json` http://jsonapi.org/extensions/#extension-negotiation
53bbd65
to
f3475f0
Compare
JSON Content-Type matcher is more inclusive
Looks good, thanks! |
Supports
the JSON API spec uses
application/vnd.api+json
http://jsonapi.org/extensions/#extension-negotiation