Skip to content
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

Grape deprecated passing options hash to desc #594

Closed
thogg4 opened this issue Mar 7, 2017 · 5 comments
Closed

Grape deprecated passing options hash to desc #594

thogg4 opened this issue Mar 7, 2017 · 5 comments

Comments

@thogg4
Copy link
Contributor

thogg4 commented Mar 7, 2017

It is now deprecated to pass an options hash to desc in grape like this:

desc 'get an object', hidden: true

As shown here:
https://github.com/ruby-grape/grape/blob/master/lib/grape/dsl/desc.rb#L50

And (as far as i can tell) passing options like that no longer has an effect when using the latest versions of grape and grape-swagger.

For example, that line above doesn't seem to hide the endpoint.

The grape project seems to prefer setting options like this now:

desc 'get an object'
route_setting :swagger, hidden: true
get '/object/:id' do

end

As described here:
https://github.com/ruby-grape/grape#describing-and-inspecting-an-api

Am I missing something?
Would you be interested in a pull request that takes this into account?

@LeFnord
Copy link
Member

LeFnord commented Mar 7, 2017

heap , this warning exists since grape 0.15.0, but it doesn't mean one can not provide options, this can be done in a block …

desc 'get an object' do
  hidden true
end

@thogg4
Copy link
Contributor Author

thogg4 commented Mar 8, 2017

@LeFnord that example was the first thing I tried. It gives me this error:

NoMethodError: undefined method hidden' for #<#Class:0x007fbb1464fad8:0x007fbb1464f150>`

@LeFnord
Copy link
Member

LeFnord commented Mar 9, 2017

it is a bit curious, cause there is a spec (https://github.com/ruby-grape/grape-swagger/blob/master/spec/swagger_v2/hide_api_spec.rb) which exactly uses your first version, without any warnings → have a look on the travis builds

the the second version raises an error, sorry I forget, that all methods of the block must be defined for grape, that is why I personally prefer the hash style, it is much more flexible and more independent form grape

by the way, have a look on the specs, the hash style is very often used, without any problems

@edgarjs
Copy link

edgarjs commented May 30, 2017

Does this cover the is_array: true option for the endpoint? For what I can see it only fixes the hidden one.

@thogg4
Copy link
Contributor Author

thogg4 commented Jun 1, 2017

@edgarjs this specific issue was addressed by #596 it doesn't cover is_array

@thogg4 thogg4 closed this as completed Jun 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants