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

Support array of params #140

Closed
avdept opened this issue Jul 2, 2014 · 6 comments
Closed

Support array of params #140

avdept opened this issue Jul 2, 2014 · 6 comments

Comments

@avdept
Copy link

avdept commented Jul 2, 2014

I have array of params passing to request like

``` select[]=current&select[]=requested&select[]=plan````

but in doc i have only first select param. How do i get rest of params to showing in generated doc?

@oestrich
Copy link
Contributor

oestrich commented Jul 2, 2014

Can you post a screenshot of the generated docs and the code you're using?

@avdept
Copy link
Author

avdept commented Jul 3, 2014

screen shot 2014-07-03 at 11 15 46 am
here is my request, and list of params. As you see i have array of select params, but in result i'm ending only with last one

@oestrich
Copy link
Contributor

oestrich commented Jul 3, 2014

Don't have time to fix this at the moment, but I believe it's failing here: https://github.com/zipmark/rspec_api_documentation/blob/master/lib/rspec_api_documentation/client_base.rb#L82

@jandillmann
Copy link
Contributor

+1 for this

@avdept
Copy link
Author

avdept commented Jul 15, 2014

I've ended up with following code

def query_hash
  hash = {}
  strings = query_string.split("&")
  strings.map do |segment|
    k,v = segment.split("=")
    hash[k]||= k.include?("[]") ? [] : nil
    k.include?("[]") ? hash[k] << CGI.unescape(v) : hash[k] = CGI.unescape(v)
  end
  hash
end    

I don't have time to make pull request, but replace this method in client_base.rb file, and it will work

@oestrich
Copy link
Contributor

I replaced that section of code with Rack::Utils.parse_nested_query. It could display nicer in Raddocs, but good enough for now.

screenshot at 10-32-07

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