-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[Rust] Split out request logic, implement form parameters #528
[Rust] Split out request logic, implement form parameters #528
Conversation
CI failure is a network or mvn flake it looks like |
92c8dd4
to
ea41745
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like what you've done - it makes the mustache templates a lot more readable. I might need to move rust-server
over to use this pattern as well.
use serde; | ||
use serde_json; | ||
|
||
pub struct ApiKey { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be pub(crate)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, updated, thanks!
@@ -0,0 +1,214 @@ | |||
use std::borrow::Cow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it necessary to have multiple copies of this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, this was a rebase mess-up to have both here; this one's gone now.
pub fn returns_nothing(mut self, val: bool) -> Self { | ||
self.no_return_type = val; | ||
self | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only ever call this with val=true
. Do we need to have val
?
parsed.map_err(|e| Error::from(e)) | ||
}) | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've not reviewed this in detail - I assume you've just copied the logic across.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More or less.
I did add minor error handling around uri parsing that was an unwrap before and restructured it a bit to make it read cleaner, but it's meant to be just a straight copy+paste.
Other than forms. I did add form parameters since those weren't present at all before.
This reduces the number of variables which are used in the generated operations, thus fixing OpenAPITools#512. This also fixed a TODO related to URI parsing errors. Other than that, it is meant to be functionally identical.
Up until now, they just weren't there at all
ea445b6
to
546f510
Compare
* Port of PR swagger-api/swagger-codegen#8804. * Correction of conflict with PR #528 (missing template file). * Add rust-reqwest samples to Circle CI tests. * Add integration test pom.xml file with launcher to trigger cargo execution. * Deduplicate Maven project name. * Fix "api_key" header for Petstore. * Better API key management. * Fix query param for lists of objects other than strings (numbers, etc.). * Update to reqwest 0.9, and refactor of header management (using reqwest transition feature). * Merge scripts generating rust-hyper and rust-reqwest samples. * Consistent full stops. * Use raw variables in all Rust mustache templates. * Replace production build in CI with a quick simple check. * Update samples. * Finish Reqwest 0.9 migration (removing "hyper 0.11" transition feature). * Configuration implements Default trait. * API template reorganized: HashMap is not required anymore. * Revert "Merge scripts generating rust-hyper and rust-reqwest samples." This reverts commit 970f996. * Remove deprecated "-XX:MaxPermSize" java arg.
…ls#528) * [Rust] Move request logic into standalone file This reduces the number of variables which are used in the generated operations, thus fixing OpenAPITools#512. This also fixed a TODO related to URI parsing errors. Other than that, it is meant to be functionally identical. * [Rust] Add support for non-file form params Up until now, they just weren't there at all * [Rust] Use more rustic terms in example
…1258) * Port of PR swagger-api/swagger-codegen#8804. * Correction of conflict with PR OpenAPITools#528 (missing template file). * Add rust-reqwest samples to Circle CI tests. * Add integration test pom.xml file with launcher to trigger cargo execution. * Deduplicate Maven project name. * Fix "api_key" header for Petstore. * Better API key management. * Fix query param for lists of objects other than strings (numbers, etc.). * Update to reqwest 0.9, and refactor of header management (using reqwest transition feature). * Merge scripts generating rust-hyper and rust-reqwest samples. * Consistent full stops. * Use raw variables in all Rust mustache templates. * Replace production build in CI with a quick simple check. * Update samples. * Finish Reqwest 0.9 migration (removing "hyper 0.11" transition feature). * Configuration implements Default trait. * API template reorganized: HashMap is not required anymore. * Revert "Merge scripts generating rust-hyper and rust-reqwest samples." This reverts commit 970f996. * Remove deprecated "-XX:MaxPermSize" java arg.
PR checklist
./bin/
to update Petstore sample so that CIs can verify the change.cc @frol @farcaller @bjgill
Description of the PR
This PR contains two changes which I needed to make for a particular swagger client to work.
The first moves most request logic into a standalone file / method. This makes it much erasier to avoid variable conflicts since the
Request.execute
method doesn't have the generatedparam
s in its scope, and as such doesn't have to worry about conflicting with them.I intend for
.execute
to behave identically to what we previously generated per operation.I did, however, also implement form data while I was at it. That is included as a second separate commit, and I can file it separately if that's preferred.
Fixes #512, #525