-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Errors with using entity documentation #1302
Comments
To me |
@dblock I took this line from readme.
|
Ok, I guess this needs a spec in Grape or Grape::Entity. You should try to do that next. |
@dblock I should write a spec? I don't understand. Documentation is a bit misleading. desc 'Returns your public timeline.' do
detail 'more details'
params Entity::Value.documentation.except(:id, :errors)
end If i want to overwrite or make field required i could do params block below but it add new param instead of overwriting previous params. And i can't use params block within desc block. desc 'Returns your public timeline.' do
params do
requires :all, Entity::Value.documentation.except(:id, :errors)
end
end This gives error lib/grape/util/strict_hash_configuration.rb:48:in `block (2 levels) in simple_settings_methods': wrong number of arguments (given 0, expected 1) (ArgumentError) |
I haven't dug through this. If the documentation says something that you're trying to do and it doesn't work, it's a bug in either the code or the doc. I'll take a look later in depth, but feel free to do what you think is right and make pull requests. I know I am not being very helpful here ;) |
@onemanstartup Did you ever find a solution to this? I'm trying to do something similar, and running into the same problem. |
I'm still working on my issue, but I've figured out a couple things:
I'm still trying to fix my problem, but if/when I do, I will submit a PR to either fix some bugs, or update the readme, or maybe both. |
Alright, I've fixed my issue. It turns out that there's a known bug with grape and active_model 4+. To fix it, I added the Before I found that, I wrote this little helper method. I hope it helps someone in the future: def validators_from_documentation(doc_hash)
validators = Grape::Validations.validators.keys.map(&:to_sym)
doc_hash.map do |k, v|
[k, v.select { |validator| validators.include?(validator) }]
end.to_h
end |
@dkniffin Yours doesn't look like a problem identical to this issue, or did I miss something? |
@dblock I did originally start with an error very similar to this:
Then I ran into several other issues. |
@onemanstartup Anty of this helps? What do we want to do with this bug? |
For me almost everything worked correctly after following @dkniffin's advice.
The only issue is that because |
@onemanstartup I'd like to close this, thanks @guavabot. Reopen with details of anything you cannot figure out. |
One more thing. This will fail if one of your parameters is |
Just want to make sure there's nothing to do in grape proper for that @guavabot. |
I was trying to migrate my params to using entities and I'm getting different types of errors. Is this grape-entity error or grape?
This is error happens first of all.
This error happens when I'm changing type to classes. I get it we don't have Boolean type in ruby and grape uses virtus, but with Integer and String type there is no errors.
The text was updated successfully, but these errors were encountered: