Skip to content

Allow skipping SnakyHash conversion

Created by: jeromepl

When trying to upgrade to v2.0 on our project, we ran into an unexpected breaking change.

OAuth2::Response#parsed still returns a hash-like object but calling to_h on it returns a Hash with differently formatted keys than before for camel-cased responses.

Before:

data = response.parsed.to_h
# > { "objectiveType"=>"WEBSITE_CONVERSIONS" }

After:

data = response.parsed.to_h
# > { "objective_type"=>"WEBSITE_CONVERSIONS" }

This could be seen as a bug, depends on your point of view. My 2 cents is that the default returned by to_h should probably correspond to the raw data received from the API, in this case the camelCase keys like it was before the upgrade to v2.