Skip to content

Commit 09fe7cd

Browse files
authored
Update OpenAPI version and templates (#296)
## 🎟️ Tracking <!-- Paste the link to the Jira or GitHub issue or otherwise describe / point to where this change is coming from. --> ## 📔 Objective Update the version of openapi generator that we use, and use the latest templates. Because of the autogenerated code, this PR is fairly big so I've split it into easier to parse commits. I recommend reviewing them individually: - [Update versions](5b8c947): Very straightforward, just bumps all the packages. This doesn't change the generated code in any way - [Update template files](82d4429): This updates the template files with the latest in the openAPI repo. Note that this is the templates as they are upstream, without our changes. The next commit will apply only our changes, so it's easy to review and rebase in the future. I basically deleted the contents of the `support/openapi-templates` and pasted the contents from here: https://github.com/OpenAPITools/openapi-generator/tree/05e672d85672a2f7a97fe0d3601aadc26d43e572/modules/openapi-generator/src/main/resources/rust Best way to validate it's correct would be to do the same thing and check that the files match. - [Make changes to templates](272d541). The changes applied are as follows: - Use the `uuid` crate type instead of strings. - Removed the double optional pattern, which was applied when types were `nullable & !required`. We don't differentiate between nullable and !required, so the double optional only adds complexity. - Updated `Cargo.toml` so it's more in line with ours. - Ignored some clippy lints - The new templates already contain support for int enums, so that's one less patch we have to do - [🤖 Generated code](fff9127): This is the autogenerated bindings built using `./support/build-api.sh` on the same server version as last time bitwarden/server@29dc69a . I haven't used a newer version to reduce the number of changes on this PR. The changes are entirely because of template updates, so rather than review it I'd recommend trying to build the bindings on top and seeing if they match: - Models are functionally identical, their Display impl is slightly different but has the same output. - API functions are restructured internally, and they now check for a JSON content type before trying to deserialize the response. - I've kept the Cargo.toml changes as they were before, because our version is updated with renovate updates. ## ⏰ 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
1 parent 1fa0f7a commit 09fe7cd

File tree

141 files changed

+18909
-16050
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+18909
-16050
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.10.0
1+
7.13.0

crates/bitwarden-api-api/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ client.
1111

1212
- API version: latest
1313
- Package version: 1.0.0
14-
- Generator version: 7.10.0
14+
- Generator version: 7.13.0
1515
- Build package: `org.openapitools.codegen.languages.RustClientCodegen`
1616

1717
## Installation

crates/bitwarden-api-api/src/apis/access_policies_api.rs

Lines changed: 448 additions & 362 deletions
Large diffs are not rendered by default.

crates/bitwarden-api-api/src/apis/accounts_api.rs

Lines changed: 1231 additions & 1291 deletions
Large diffs are not rendered by default.

crates/bitwarden-api-api/src/apis/accounts_billing_api.rs

Lines changed: 136 additions & 151 deletions
Large diffs are not rendered by default.

crates/bitwarden-api-api/src/apis/accounts_key_management_api.rs

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*/
1010

1111
use reqwest;
12-
use serde::{Deserialize, Serialize};
12+
use serde::{de::Error as _, Deserialize, Serialize};
1313

14-
use super::{configuration, Error};
14+
use super::{configuration, ContentType, Error};
1515
use crate::{apis::ResponseContent, models};
1616

1717
/// struct for typed errors of method [`accounts_key_management_regenerate_keys_post`]
@@ -25,42 +25,40 @@ pub async fn accounts_key_management_regenerate_keys_post(
2525
configuration: &configuration::Configuration,
2626
key_regeneration_request_model: Option<models::KeyRegenerationRequestModel>,
2727
) -> Result<(), Error<AccountsKeyManagementRegenerateKeysPostError>> {
28-
let local_var_configuration = configuration;
28+
// add a prefix to parameters to efficiently prevent name collisions
29+
let p_key_regeneration_request_model = key_regeneration_request_model;
2930

30-
let local_var_client = &local_var_configuration.client;
31-
32-
let local_var_uri_str = format!(
31+
let uri_str = format!(
3332
"{}/accounts/key-management/regenerate-keys",
34-
local_var_configuration.base_path
33+
configuration.base_path
3534
);
36-
let mut local_var_req_builder =
37-
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
35+
let mut req_builder = configuration
36+
.client
37+
.request(reqwest::Method::POST, &uri_str);
3838

39-
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
40-
local_var_req_builder =
41-
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
39+
if let Some(ref user_agent) = configuration.user_agent {
40+
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
4241
}
43-
if let Some(ref local_var_token) = local_var_configuration.oauth_access_token {
44-
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
42+
if let Some(ref token) = configuration.oauth_access_token {
43+
req_builder = req_builder.bearer_auth(token.to_owned());
4544
};
46-
local_var_req_builder = local_var_req_builder.json(&key_regeneration_request_model);
45+
req_builder = req_builder.json(&p_key_regeneration_request_model);
4746

48-
let local_var_req = local_var_req_builder.build()?;
49-
let local_var_resp = local_var_client.execute(local_var_req).await?;
47+
let req = req_builder.build()?;
48+
let resp = configuration.client.execute(req).await?;
5049

51-
let local_var_status = local_var_resp.status();
52-
let local_var_content = local_var_resp.text().await?;
50+
let status = resp.status();
5351

54-
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
52+
if !status.is_client_error() && !status.is_server_error() {
5553
Ok(())
5654
} else {
57-
let local_var_entity: Option<AccountsKeyManagementRegenerateKeysPostError> =
58-
serde_json::from_str(&local_var_content).ok();
59-
let local_var_error = ResponseContent {
60-
status: local_var_status,
61-
content: local_var_content,
62-
entity: local_var_entity,
63-
};
64-
Err(Error::ResponseError(local_var_error))
55+
let content = resp.text().await?;
56+
let entity: Option<AccountsKeyManagementRegenerateKeysPostError> =
57+
serde_json::from_str(&content).ok();
58+
Err(Error::ResponseError(ResponseContent {
59+
status,
60+
content,
61+
entity,
62+
}))
6563
}
6664
}

0 commit comments

Comments
 (0)