-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[Elixir] Use string headers #19759
[Elixir] Use string headers #19759
Conversation
Hi @ntodd, Oh, I wasn’t aware of that - thank you very much for the PR and for pointing it out! The changes look good to me, although I’d like to run a quick test in the wild just to make sure it won’t cause any issues with the default adapter. If everything checks out, we should be good to merge this PR by tomorrow. Thanks again! |
Hi @ntodd Your proposed changes look good, but I noticed that this won't affect how optional parameters are handled. Those values are still stored as atoms. From the implementation perspective, I think it would make more sense to only change the function What do you think? |
@mrmstn I have no problem with this, but I won't have a chance to tackle it for a while. I'd be happy to review and verify, however. |
@mrmstn I updated |
local tests passed. thanks for your PR. let's give it a try |
@ntodd when you've time next week, can you please PM me via Slack? https://join.slack.com/t/openapi-generator/shared_invite/zt-2uoef5v0g-XGwo8~2oJ3EoziDSO1CmdQ |
Currently, generated API modules set headers with the following function:
This works well with the default Tesla adapter, but when changing the adapter to Finch, I got errors that Mint was trying to call
String.downcase/2
on the atom key causing a FunctionClauseError.Additionally, Tesla expects headers as a keyword list of binaries (e.g.
[{"Foo-Id", "1234"}]
not[{"Foo-Id", 1234}]
. If a non-string header value is provided,Mint.HTTP1.Request.validate_header_value/2
will throw:invalid_header_value
. Again, this was only observed when changing the default adapter, but does follow the spec expected by Tesla.put_headers/2 so it should probably be changed regardless.This PR does two things:
add_param/4
function to use"Foo-Id"
rather than:"Foo-Id"
Kernel.to_string/1
on the header value to ensure it is a binary valuePR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master
(upcoming7.x.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)@mrmstn