-
Couldn't load subscription status.
- Fork 20
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
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
This comment was marked as outdated.
This comment was marked as outdated.
689da35 to
d98d249
Compare
60d0b85 to
f867177
Compare
This comment was marked as outdated.
This comment was marked as outdated.
d4c8e00 to
90007b7
Compare
This comment was marked as outdated.
This comment was marked as outdated.
96e306e to
320ea80
Compare
320ea80 to
cfc6a0a
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've reviewed all code except the auto generated which i've confirmed matches the output from manually running it.
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.
Auth file change LGTM!
|
โฆo use the `reqwest-trait` template (bitwarden/sdk-internal#343)
## ๐๏ธ Tracking <!-- Paste the link to the Jira or GitHub issue or otherwise describe / point to where this change is coming from. --> ## ๐ Objective In #343 I've made the bindings traits always ?Send as the `reqwest` client on WASM is not Send. The issue is that this introduces problems for other SDK clients where that require the code to be Send, for example NAPI, which is used by Secrets Manager. This PR updates the bindings to be ?Send only for the WASM architecture. ## โฐ Reminders before review - Contributor guidelines followed - All formatters and local linters executed and passed - Written new unit and / or integration tests where applicable - Protected functional changes with optionality (feature flags) - Used internationalization (i18n) for all UI strings - CI builds passed - Communicated to DevOps any deployment requirements - Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team ## ๐ฆฎ Reviewer guidelines <!-- Suggested interactions but feel free to use (or not) as you desire! --> - ๐ (`:+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 confirmed issue 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



๐๏ธ Tracking
https://bitwarden.atlassian.net/browse/PM-25542
๐ Objective
Note: The PR is absolutely massive because the generated code is very verbose (something that I plan to optimize in the future) and github is pretty bad about filtering out whitespace changes ๐. To facilitate review I include some recommendations at the bottom of this block.
This template is trait based which should allow easier mocking. It also follows a similar pattern to our clients which I think would make it easier to use:
The provided mocks are also typesafe and easy to use:
PR structure
The PR is split 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/ee40887d47f6d7a16318772f49c63b8eb0553488/modules/openapi-generator/src/main/resources/rust I've also gone ahead and deleted some unused files to make it clearer which files are being used.Add our changes to the templatesREADME.mustache: Added the server commit hash to the readmemodel.mustacheandmodel_mod.mustache: Remove double option pattern, as we don't differentiate between not required and nullable, and they just add noise.api.mustache: Made async-traits ?Send to support WASMapi.mustache: Used our customx-action-nameinstead ofoperationID, so that function names are justfunctionNameinstead ofControllerName_FunctionNameapi.mustache: Filtered deprecated operations out, no need to generate code for them when they shouldn't be usedapi.mustache: Useuuidinstead of&strfor request parametersapi.mustache: Replaced all the function lifetimes by a single one. Previously it would create one per parameter, which is more flexible but made for some terrible function signatures.api_mod.mustache: Replaced the root Api trait and implementations by a single ApiClient enum with both real and mock impls. This is functionally the same but allows the compiler to better optimize out the unused functions (from 3.7MB to 2.2MB WASM blob size)๐ค Generate bindings: Generate the bindings using the template from the previous step. this is based on the server bindings from bitwarden/server@d384c0cUpdate 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.rsfile and consist in modifications to how we initialize and update theApiConfigurationsstruct 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/auth
Filter by team owned, the vault/auth related changes are fairly small:
If filtering by team owned doesn't work, the non-platform changes are contained entirely in the fourth commit: 320ea80
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:
โฐ 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