-
Notifications
You must be signed in to change notification settings - Fork 472
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
Parameters delimited by dash cause exception #586
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @risa
@@ -0,0 +1,24 @@ | |||
require 'spec_helper' | |||
|
|||
describe '#XXX nested entity given as string' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please can you adapt the description, e.g. https://github.com/ruby-grape/grape-swagger/blob/master/spec/issues/582_file_response_spec.rb#L3 and also rename the spec file itself,
starting with issue number, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the naming, my first PR ever ... should I open an issue for this, to get the number?
result | ||
end | ||
|
||
specify { expect(subject.keys).to include '/range_parameter/range/{range_start}-{range_end}' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you show the operationId
, how this had changed, thanks
[please add changelog entry, as the bot suggest |
thanks again |
Thanks as well! |
* Fixed range parameters delimited by dash * fixed rubocop offense * updates for requested changes - renamed spec and showed operationId value in spec * Changelog updated
In our project we are using api calls to return a range from array, like this:
get '/range/:range_start-:range_end'
Currently this causes
NoMethodError: undefined method
delete!' for nil:NilClass./lib/grape-swagger/doc_methods/operation_id.rb:22:in
manipulate'
See the spec below for demostration.
The problem is caused by difference between regexp
/\-(\w)/
and include?('-'). The path gets translated to operation: "Range_parameterRange{range_start}-{range_end}". The include?('-') matches the string but the regexp does not. And per specs the gsub! returns nil if no substitutions were made (not the least surprise principle for me).We are using only dash, possibly underscore can be offending as well, but as a first attempt I suggest only dash.
Suggestions and feedback welcome. Thanks.