[Rust][reqwest] various improvements#1890
Conversation
|
FYI. The change in body parameter name is due to an enhancement to preserve body parameter name defined in OAS v2 spec |
Thanks. I wondered about that when I regenerated the samples. But since the code still compiled, I didn't investigate further. |
|
If no question/feedback from anyone, I'll merge this PR tomorrow. |
| let mut form_params = HashMap::new(); | ||
| {{#formParams}} | ||
| {{#isFile}} | ||
| form_params.insert("{{{baseName}}}".to_string(), unimplemented!()); |
There was a problem hiding this comment.
I've given this a quick skim. As a thought, when do we want to fail if a user does attempt to create a generator with a file form parameter? This unimplemented would mean that we would fail at run-time when that endpoint was called.
Might it be worth using compile_error! (https://doc.rust-lang.org/std/macro.compile_error.html) so that the user discovers this at compile time instead?
There was a problem hiding this comment.
compile_error!("File form parameters not supported by the rust generator");, perhaps?
There was a problem hiding this comment.
I ported the Hyper implementation (cf #525). We can switch to compile_error! macro, but we probably should do the same in hyper library templates to be consistent.
There was a problem hiding this comment.
I tested compile_error! macro and I am questioning…
Since petstore example contains a file form param, with this macro, generated sample code does not compile anymore: the project cannot be used anymore to check syntax error regressions, for example.
So, I suggest keeping unimplemented!.
…ons (with file params) in Reqwest library.
|
Looking for @bjgill comment, I kept |
bjgill
left a comment
There was a problem hiding this comment.
LGTM
.
Just one minor point for future reference - this PR seems to add a number of blank lines. If you have only one mustache tag per line, you can avoid these sort of extra blank lines. Not a big deal, though - no need to fix for this PR.
|
@bjgill Oh, Thanks for the advice. I am not familiar with mustache… I used several tags by line specially because I thought it could reduce blank lines. I will fix that next time I have an evolution to implement. |
* Resolves OpenAPITools#525 for Rust client generator with reqwest library. * Use Reqwest "query" method to generate query URL. * urlencode URL string parameters. * Generate rust-reqwest client, and verify it compiles and work as intended. * Map file params (to "&std::path::Path") and support multipart operations (with file params) in Reqwest library. * Cleanup: template compression to remove unecessary blank lines in generated code.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.master,. Default:3.4.x,4.0.xmaster./cc @frol @farcaller @bjgill
Description of the PR
This PR contains 3 improvements of the rust client generator with Reqwest library: