Open bobbytables opened 5 years ago
We're hitting this too, in a way. Calling .as_json
doesn't seem to return a hash for nested entities. Oddly, calling .to_json
will return a string that has been properly recursed and converted to json.
In other words, calling .as_json
converts the top level entity to a hash, but nested entities remain as type: Grape::Entity::Exposure::NestingExposure::OutputBuilder
. This means you can't do things like deep_stringify_keys
or otherwise work with this structure.
I'm not sure, but I would guess you need to call .as_json
for every level of nesting, its not just that its magically needing to call it twice.
Tested this with latest 0.9.0 version
Hi! I'm trying to use my entity to ensure the returned data in the API matches what my Entity should be exposing in a RSpec request spec in my rails application.
I'm doing this:
This makes my test pass, but why do I have to call
#as_json
twice? This feels weird to me and I don't see a method on theGrape::Entity
class that gives me what I want. More of a question than a bug but I see room for improvement here.Thanks!