-
Notifications
You must be signed in to change notification settings - Fork 1
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
String parameter values are escaped in generated doc #8
Comments
I think we need to fix |
Also need to change I tried this over the weekend, and it worked: def request_path
URI::unescape(@_group.request.fullpath) unless @_group.request.nil?
end But I'm not sure if we need to somehow only unescape the query params, or if we should just unescape the whole thing. |
I believe Ruby has marked What we need to do is either find a different escape method which won't escape colons or find a way to configure the escaping to not escape colons. |
We could monkeypatch class String
def to_query(key)
"#{CGI.escape(key.to_param)}=#{to_param}"
end
end Or we could create a "presenter" type object class that implements that, and then you'd have to use it whenever you want to inhibit escaping. Both of those things could be done in the host app, rather than in this gem. This is what Rails does to do the escaping. |
So here's what I've got so far that I like - in the host app, I'm doing this: class DoNotEscape < SimpleDelegator
def to_query(key)
"#{CGI.escape(key.to_param)}=#{to_param}"
end
end
class ::Object
def not_escaped
DoNotEscape.new(self)
end
end Then you can define your params like this: {
start_time: "2020-04-20T00:00:00Z".not_escaped,
end_time: "2020-04-20T23:59:59Z".not_escaped,
} |
Oh right, ruby-doc recommends using I've never used delegators so I will spend a little time reading up on them, but this seems like the favorable approach over 🙈-patching. |
When passing parameters in the API call with an iso8601 datetime parameter like this
the generated docs end up escaping the
:
s (and probably does for other special characters)I haven't dug into where the http routes are being generated, but we should be able to fix by unescaping.
The text was updated successfully, but these errors were encountered: