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

Ruby client - capitalized parameters are converted incorrectly #253

Closed
xhh opened this issue Aug 27, 2014 · 2 comments
Closed

Ruby client - capitalized parameters are converted incorrectly #253

xhh opened this issue Aug 27, 2014 · 2 comments

Comments

@xhh
Copy link
Contributor

xhh commented Aug 27, 2014

For capitalized query/header parameters, the generated Ruby code converts them to underscore format with leading underscore, e.g. "MyHeader" => "_my_header".

For example, for parameters "MyPath", "MyQuery", "MyHeader" and "MyForm", the following is the generated code:

def self.my_method (event_id,_my_path,_my_header,_my_query,_my_form,opts={})
    query_param_keys = [:_my_query]

    # verify existence of params
    raise "event_id is required" if event_id.nil?
    raise "_my_path is required" if _my_path.nil?
    # set default values and merge with input
    options = {
    :event_id => event_id,
      :_my_path => _my_path,
      :_my_header => _my_header,
      :_my_query => _my_query,
      :_my_form => _my_form}.merge(opts)

    #resource path
    path = "/event/:event_id:/{MyPath}".sub('{format}','json').sub('{' + 'event_id' + '}', escapeString(event_id))
    .sub('{' + 'MyPath' + '}', escapeString(_my_path))

    # pull querystring keys from options
    queryopts = options.select do |key,value|
      query_param_keys.include? key
    end

    headers = {
      _my_header: _my_header,
    }
    post_body = nil
    response = Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
    MyModel.new(response)

  end

The path parameter works here. Query and header parameters are using incorrect keys. The form parameter is not used at all.

@wing328
Copy link
Contributor

wing328 commented Aug 27, 2014

on a similar topic, would it be better to simply append an underscore (_) to parameter name starting with capital letter?

for example, the current approach will convert TOKEN into _t_o_k_e_n and I would suggest converting it into _TOKEN instead

@xhh
Copy link
Contributor Author

xhh commented Apr 17, 2015

This is fixed by #649.

@xhh xhh closed this as completed Apr 17, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants