-
Notifications
You must be signed in to change notification settings - Fork 14
Update bindings to use the reqwest-trait
template
#343
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
base: main
Are you sure you want to change the base?
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Should we open upstream issues and see if any of the changes can upstreamed? It would be interesting to see how the mocked usage would be as a comparison to using wiremock. |
285bb80
to
94dbf76
Compare
I'm planning to upstream the doc link issue at least, which clearly seems like a mistake. Probably also the removing Send bound, which seems safe. The rest could be harder:
The mocks look something like this: 77e2333 |
689da35
to
d98d249
Compare
60d0b85
to
f867177
Compare
@@ -36,7 +36,7 @@ impl Configuration { | |||
impl Default for Configuration { | |||
fn default() -> Self { | |||
Configuration { | |||
base_path: "http://localhost".to_owned(), | |||
base_path: "https://identity.bitwarden.com".to_owned(), |
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.
Could this be potentially dangerous? We should never use the default config as we don't know if it's EU or US.
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 never use this default, we use the value from ClientSettings
:
sdk-internal/crates/bitwarden-core/src/client/client_settings.rs
Lines 38 to 45 in c3d62e3
impl Default for ClientSettings { | |
fn default() -> Self { | |
Self { | |
identity_url: "https://identity.bitwarden.com".into(), | |
api_url: "https://api.bitwarden.com".into(), | |
user_agent: "Bitwarden Rust-SDK".into(), | |
device_type: DeviceType::SDK, | |
} |
Moving to draft for now as the compiler can't seem to optimize the unused trait impls away, leading to 2x file sizes for the final wasm bundle. I'll look into modifying the generated code to not be as resource heavy. Edit: I have some improvements to the generated code that reduce the size of the binary considerably, but they are deeper changes into the templates that will benefit from upstreaming, so for now I've commented out the use of traits in this PR, and I will revisit that in a separate PR when I'm back from vacation. |
f867177
to
c3d62e3
Compare
c3d62e3
to
d4c8e00
Compare
d4c8e00
to
90007b7
Compare
|
🎟️ Tracking
📔 Objective
This template
is trait based which should allow easier mocking. It alsofollows a similar pattern to our clients which I think would make it easier to use.The PR is in four commits:
Update OpenAPI and templates to latest version
: Updates the openapi generator and the templates to the latest version. These files should match with the files at https://github.com/OpenAPITools/openapi-generator/tree/98b315c13717adf13d00011787eab915b64d3a14/modules/openapi-generator/src/main/resources/rust I've also gone ahead and deleted some unused files, and added others to.openapi-generator-ignore
, to make it clearer which files are being used.Add our changes to the templates
uuid
instead of&str
🤖 Generate bindings
: Generate the bindings using the template from the previous step. this is based on the same server bindings as [PM-22256] - Updating OpenAPI bindings #366Update code to new api
. Updated our code to build with the new template, most changes are very simple API adjustments, the biggest changes are in theclient/internal.rs
file and consist in modifications to how we initialize and update theApiConfigurations
struct to match the newer API.PR review recommendation
As this PR edits the generated bindings, the total changes are huge and difficult to review. As such, I've written a suggested review guide for the teams.
For vault
Filter by team owned, the vault related changes are fairly small:
The changes are contained entirely in the last commit: 90007b7
For platform
Due to the big autogenerated changes, I recommend reviewing commit by commit. The first, third and fourth commits should be reviewed as normal. The second commit, marked as 🤖, should instead be reviewed by regenerating the bindings and making sure that nothing is changed:
I have a server PR including a script to make this easier next time: bitwarden/server#6066
⏰ Reminders before review
team
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmedissue and could potentially benefit from discussion
:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes