-
Notifications
You must be signed in to change notification settings - Fork 416
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
Fix RequestFactory gsub for base_path_from_servers #591
Conversation
Commit 2264b03 introduced a change to this method where the gsub replacement of the server url switched from the global Regexp match variable of \$1 to the block argument for gsub. This change made it so that the argument to the variable name lookup include the braces used in the string for the url variable. That lead to the hash not returing any matching keys and values and the generated URI string of '://' being passed to the URI() method which raise an error.
Co-authored-by: Julien Girard <julien09girard@gmail.com>
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.
@saturnflyer Thank you for fixing it!
Please, just update the CHANGELOG.md
with the PR number and document the change in README.md
examples. Than it's good to be merged 👍
A change in test-app would also be nice for demonstration. |
Co-authored-by: Roman Blanco <1187051+romanblanco@users.noreply.github.com>
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.
LGTM 👍, Thank you, @saturnflyer!
Problem
Commit 2264b03 introduced a change to this method where the gsub replacement of the server url switched from the global Regexp match variable of $1 to the block argument for gsub.
This change made it so that the argument to the variable name lookup include the braces used in the string for the url variable.
That lead to the hash not returing any matching keys and values and the generated URI string of '://' being passed to the URI() method which raise an error.
Solution
The solution is to
useuse the global Regextr
to replace matching{
and}
characters from the block argument passed togsub!
$1
match variable inRswag::Specs::RequestFactory#base_path_from_servers
This concerns this parts of the Open API Specification:
protocol
The changes I made are compatible with:
Related Issues
None
Checklist
Steps to Test or Reproduce
The configuration in the spec was updated to include a
protocol
value in the server variables with a:default
key. Only this change is necessary to trigger an Invalid URI error.