Skip to content

Curl output removes '_ID' Suffix from headers #361

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

Open
jlbyrne opened this issue Oct 30, 2017 · 1 comment
Open

Curl output removes '_ID' Suffix from headers #361

jlbyrne opened this issue Oct 30, 2017 · 1 comment

Comments

@jlbyrne
Copy link

jlbyrne commented Oct 30, 2017

I noticed a strange issue when trying to debug a problem in our documentation. Within the generated curl request, one of our headers is showing up as 'X-Api-Partner' instead of the correct 'X-Api-Partner-Id'.

I traced the problem back to rspec_api_documentation/lib/rspec_api_documentation/curl.rb:68. The format_header method is using titleize to capitalize the header name. Titleize unfortunately strips out '_id' suffixes, because it calls humanize. rails/rails#26011

Could you update the format_header method to use something other than titleize? I was thinking something like this would work:

header.gsub(/^HTTP_/, '').split(/ |\_|\-/).map(&:capitalize).join('-')

Thank you.

@mroach
Copy link

mroach commented Aug 21, 2018

Ouch. I can imagine you banged you head on the wall for a while on that one. Big +1 on not using titleize. I'd even go a step further and just downcase the whole header. This is the approach being taken in the Phoenix/Plug framework which I think makes sense. Then everyone knows headers are just lower-case all the time and it's easy to deal with.

I'm wondering why the HTTP_ prefix is being stripped out here too. If memory serves this header prefix only ever appeared in PHP and ASP Classic.

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

2 participants