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

[Rust] Support for withAWSV4Signature option #11690

Merged
merged 3 commits into from
Mar 1, 2022

Conversation

jerome-jutteau
Copy link
Contributor

Hi @farcaller

This PR is about supporting AWSV4Signature in rust generator (see issue #11193).

Few notes:

  • Option is by default set to false
  • Only reqwest is supported for now (non-async)
  • Created a new petstore sample folder with it's pom.xml and seems to be OK.
  • Put in a separate commit other samples/client/petstore/rust/* which seems to have changed
  • PR is based on master

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    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*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (5.3.0), 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

"{{{httpMethod}}}",
{{#hasBodyParam}}
{{#bodyParams}}
&serde_json::to_string(&{{{paramName}}}).unwrap(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this is generally a safe unwrap I'd think that an expect with some context would have been more useful.

#[derive(Debug, Clone)]
pub struct AWSv4Key {
pub access_key: String,
pub secret_key: String,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be wrapped in something like secrecy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't knew about secrecy, I will fix this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I don't insist on secrecy specifically (just happens to be the one I've used).

.build()
.unwrap();
let signable_request = SignableRequest::from(&request);
let (mut signing_instructions, _signature) = sign(signable_request, &signing_params).unwrap().into_parts();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit concerned about all the unwraps in here. Maybe propagate them up the stack proper instead?

@jerome-jutteau
Copy link
Contributor Author

Hi @farcaller, thanks for your review. I pushed a new version which should fix what you pointed out.

Copy link
Contributor

@farcaller farcaller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your updates, this looks solid.

@farcaller
Copy link
Contributor

@wing328 what's with the failing node2 test?

@wing328
Copy link
Member

wing328 commented Mar 1, 2022

@farcaller please kindly ignore the circleci node 2 failure.

@wing328
Copy link
Member

wing328 commented Mar 1, 2022

Tested the new samples (option) locally and the result is good:

   Compiling petstore-reqwest-awsv4signature v1.0.0 (/Users/williamcheng/Code/openapi-generator/samples/client/petstore/rust/reqwest/petstore-awsv4signature)
    Finished dev [unoptimized + debuginfo] target(s) in 6m 02s
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  06:04 min
[INFO] Finished at: 2022-03-02T01:15:49+08:00
[INFO] ------------------------------------------------------------------------

Other Rust tests passed via https://app.travis-ci.com/github/OpenAPITools/openapi-generator/builds/247229008

@wing328 wing328 merged commit 21f649e into OpenAPITools:master Mar 1, 2022
@jerome-jutteau jerome-jutteau deleted the rust-aws-v4 branch March 2, 2022 08:24
@wing328
Copy link
Member

wing328 commented Mar 2, 2022

FYI. I've pushed 8c023fa to replace tabs with 4-space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants