You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using :expose and specifying the exposure as safe: true, objects of the type Hash seem to never get exposed. It does not matter whether the Hash contains a key that matches the attribute.
If i mark the :exposewith safe: false, the response does show the value of the Hash, but of course only as long as the Hash has such a key.
A quick lookup in the source showed me the valid_exposure? method in the entity.rb (around line 570) to be the issue. This is the current check:
What I don't understand (I'm quite new to ruby and especially grape) is the third line, which actually says that safe exposures are not valid, unless they have nested elements or have a :proc block.
Nevertheless, similar to the fourth line, which checks for a method matching the attribute's name, I would have added a fifth condition that checks if the object is a Hash and does have a key matching the attribute's name:
This would resolve my issue and be more in line with the implementation of the primary output of the serializable_hash method, which does resolve the values of Hash objects.
Can s.o. please verify my issue?
Thank you all!
The text was updated successfully, but these errors were encountered:
When using
:expose
and specifying the exposure assafe: true
, objects of the typeHash
seem to never get exposed. It does not matter whether theHash
contains a key that matches the attribute.If i mark the
:expose
withsafe: false
, the response does show the value of theHash
, but of course only as long as theHash
has such a key.A quick lookup in the source showed me the
valid_exposure?
method in the entity.rb (around line 570) to be the issue. This is the current check:What I don't understand (I'm quite new to ruby and especially grape) is the third line, which actually says that safe exposures are not valid, unless they have nested elements or have a
:proc
block.Nevertheless, similar to the fourth line, which checks for a method matching the attribute's name, I would have added a fifth condition that checks if the object is a
Hash
and does have a key matching the attribute's name:This would resolve my issue and be more in line with the implementation of the primary output of the
serializable_hash
method, which does resolve the values ofHash
objects.Can s.o. please verify my issue?
Thank you all!
The text was updated successfully, but these errors were encountered: