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

[PM-6165] Update bindings with enum names #594

Merged
merged 7 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,7 @@ ASPNETCORE_ENVIRONMENT=development dotnet swagger tofile --output ../../identity
Runs from the root of the SDK project.

```bash
npx openapi-generator-cli generate \
-i ../server/api.json \
-g rust \
-o crates/bitwarden-api-api \
--package-name bitwarden-api-api \
-t ./support/openapi-template \
--additional-properties=packageVersion=1.0.0

npx openapi-generator-cli generate \
-i ../server/identity.json \
-g rust \
-o crates/bitwarden-api-identity \
--package-name bitwarden-api-identity \
-t ./support/openapi-template \
--additional-properties=packageVersion=1.0.0
./support/build-api.sh
```

OpenApi Generator works using templates, we have customized our templates to work better with our
Expand Down
2 changes: 0 additions & 2 deletions crates/bitwarden-api-api/.openapi-generator-ignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,3 @@
docs/*.md
.travis.yml
git_push.sh

src/models/organization_user_status_type.rs
1 change: 1 addition & 0 deletions crates/bitwarden-api-api/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ src/models/organization_user_public_key_response_model_list_response_model.rs
src/models/organization_user_reset_password_details_response_model.rs
src/models/organization_user_reset_password_enrollment_request_model.rs
src/models/organization_user_reset_password_request_model.rs
src/models/organization_user_status_type.rs
src/models/organization_user_type.rs
src/models/organization_user_update_groups_request_model.rs
src/models/organization_user_update_request_model.rs
Expand Down
50 changes: 25 additions & 25 deletions crates/bitwarden-api-api/src/models/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,41 @@
Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr,
)]
pub enum Algorithm {
Variant65535 = -65535,
Variant259 = -259,
Variant258 = -258,
Variant257 = -257,
Variant47 = -47,
Variant39 = -39,
Variant38 = -38,
Variant37 = -37,
Variant36 = -36,
Variant35 = -35,
Variant8 = -8,
Variant7 = -7,
RS1 = -65535,
RS512 = -259,
RS384 = -258,
RS256 = -257,
ES256K = -47,
PS512 = -39,
PS384 = -38,
PS256 = -37,
ES512 = -36,
ES384 = -35,
EdDSA = -8,
ES256 = -7,
}

impl ToString for Algorithm {
fn to_string(&self) -> String {
match self {
Self::Variant65535 => String::from("-65535"),
Self::Variant259 => String::from("-259"),
Self::Variant258 => String::from("-258"),
Self::Variant257 => String::from("-257"),
Self::Variant47 => String::from("-47"),
Self::Variant39 => String::from("-39"),
Self::Variant38 => String::from("-38"),
Self::Variant37 => String::from("-37"),
Self::Variant36 => String::from("-36"),
Self::Variant35 => String::from("-35"),
Self::Variant8 => String::from("-8"),
Self::Variant7 => String::from("-7"),
Self::RS1 => String::from("-65535"),
Self::RS512 => String::from("-259"),
Self::RS384 => String::from("-258"),
Self::RS256 => String::from("-257"),
Self::ES256K => String::from("-47"),
Self::PS512 => String::from("-39"),
Self::PS384 => String::from("-38"),
Self::PS256 => String::from("-37"),
Self::ES512 => String::from("-36"),
Self::ES384 => String::from("-35"),
Self::EdDSA => String::from("-8"),
Self::ES256 => String::from("-7"),
}
}
}

impl Default for Algorithm {
fn default() -> Algorithm {
Self::Variant65535
Self::RS1
}
}
14 changes: 7 additions & 7 deletions crates/bitwarden-api-api/src/models/auth_request_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@
Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr,
)]
pub enum AuthRequestType {
Variant0 = 0,
Variant1 = 1,
Variant2 = 2,
AuthenticateAndUnlock = 0,
Unlock = 1,
AdminApproval = 2,
}

impl ToString for AuthRequestType {
fn to_string(&self) -> String {
match self {
Self::Variant0 => String::from("0"),
Self::Variant1 => String::from("1"),
Self::Variant2 => String::from("2"),
Self::AuthenticateAndUnlock => String::from("0"),
Self::Unlock => String::from("1"),
Self::AdminApproval => String::from("2"),
}
}
}

impl Default for AuthRequestType {
fn default() -> AuthRequestType {
Self::Variant0
Self::AuthenticateAndUnlock
}
}
34 changes: 0 additions & 34 deletions crates/bitwarden-api-api/src/models/bitwarden_product_type.rs

This file was deleted.

10 changes: 5 additions & 5 deletions crates/bitwarden-api-api/src/models/cipher_reprompt_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr,
)]
pub enum CipherRepromptType {
Variant0 = 0,
Variant1 = 1,
None = 0,
Password = 1,
}

impl ToString for CipherRepromptType {
fn to_string(&self) -> String {
match self {
Self::Variant0 => String::from("0"),
Self::Variant1 => String::from("1"),
Self::None => String::from("0"),
Self::Password => String::from("1"),
}
}
}

impl Default for CipherRepromptType {
fn default() -> CipherRepromptType {
Self::Variant0
Self::None
}
}

This file was deleted.

18 changes: 9 additions & 9 deletions crates/bitwarden-api-api/src/models/cipher_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@
Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr,
)]
pub enum CipherType {
Variant1 = 1,
Variant2 = 2,
Variant3 = 3,
Variant4 = 4,
Login = 1,
SecureNote = 2,
Card = 3,
Identity = 4,
}

impl ToString for CipherType {
fn to_string(&self) -> String {
match self {
Self::Variant1 => String::from("1"),
Self::Variant2 => String::from("2"),
Self::Variant3 => String::from("3"),
Self::Variant4 => String::from("4"),
Self::Login => String::from("1"),
Self::SecureNote => String::from("2"),
Self::Card => String::from("3"),
Self::Identity => String::from("4"),
}
}
}

impl Default for CipherType {
fn default() -> CipherType {
Self::Variant1
Self::Login
}
}
106 changes: 53 additions & 53 deletions crates/bitwarden-api-api/src/models/device_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,69 +14,69 @@
Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize_repr, Deserialize_repr,
)]
pub enum DeviceType {
Variant0 = 0,
Variant1 = 1,
Variant2 = 2,
Variant3 = 3,
Variant4 = 4,
Variant5 = 5,
Variant6 = 6,
Variant7 = 7,
Variant8 = 8,
Variant9 = 9,
Variant10 = 10,
Variant11 = 11,
Variant12 = 12,
Variant13 = 13,
Variant14 = 14,
Variant15 = 15,
Variant16 = 16,
Variant17 = 17,
Variant18 = 18,
Variant19 = 19,
Variant20 = 20,
Variant21 = 21,
Variant22 = 22,
Variant23 = 23,
Variant24 = 24,
Variant25 = 25,
Android = 0,
iOS = 1,
ChromeExtension = 2,
FirefoxExtension = 3,
OperaExtension = 4,
EdgeExtension = 5,
WindowsDesktop = 6,
MacOsDesktop = 7,
LinuxDesktop = 8,
ChromeBrowser = 9,
FirefoxBrowser = 10,
OperaBrowser = 11,
EdgeBrowser = 12,
IEBrowser = 13,
UnknownBrowser = 14,
AndroidAmazon = 15,
UWP = 16,
SafariBrowser = 17,
VivaldiBrowser = 18,
VivaldiExtension = 19,
SafariExtension = 20,
SDK = 21,
Server = 22,
WindowsCLI = 23,
MacOsCLI = 24,
LinuxCLI = 25,
}

impl ToString for DeviceType {
fn to_string(&self) -> String {
match self {
Self::Variant0 => String::from("0"),
Self::Variant1 => String::from("1"),
Self::Variant2 => String::from("2"),
Self::Variant3 => String::from("3"),
Self::Variant4 => String::from("4"),
Self::Variant5 => String::from("5"),
Self::Variant6 => String::from("6"),
Self::Variant7 => String::from("7"),
Self::Variant8 => String::from("8"),
Self::Variant9 => String::from("9"),
Self::Variant10 => String::from("10"),
Self::Variant11 => String::from("11"),
Self::Variant12 => String::from("12"),
Self::Variant13 => String::from("13"),
Self::Variant14 => String::from("14"),
Self::Variant15 => String::from("15"),
Self::Variant16 => String::from("16"),
Self::Variant17 => String::from("17"),
Self::Variant18 => String::from("18"),
Self::Variant19 => String::from("19"),
Self::Variant20 => String::from("20"),
Self::Variant21 => String::from("21"),
Self::Variant22 => String::from("22"),
Self::Variant23 => String::from("23"),
Self::Variant24 => String::from("24"),
Self::Variant25 => String::from("25"),
Self::Android => String::from("0"),
Self::iOS => String::from("1"),
Self::ChromeExtension => String::from("2"),
Self::FirefoxExtension => String::from("3"),
Self::OperaExtension => String::from("4"),
Self::EdgeExtension => String::from("5"),
Self::WindowsDesktop => String::from("6"),
Self::MacOsDesktop => String::from("7"),
Self::LinuxDesktop => String::from("8"),
Self::ChromeBrowser => String::from("9"),
Self::FirefoxBrowser => String::from("10"),
Self::OperaBrowser => String::from("11"),
Self::EdgeBrowser => String::from("12"),
Self::IEBrowser => String::from("13"),
Self::UnknownBrowser => String::from("14"),
Self::AndroidAmazon => String::from("15"),
Self::UWP => String::from("16"),
Self::SafariBrowser => String::from("17"),
Self::VivaldiBrowser => String::from("18"),
Self::VivaldiExtension => String::from("19"),
Self::SafariExtension => String::from("20"),
Self::SDK => String::from("21"),
Self::Server => String::from("22"),
Self::WindowsCLI => String::from("23"),
Self::MacOsCLI => String::from("24"),
Self::LinuxCLI => String::from("25"),
}
}
}

impl Default for DeviceType {
fn default() -> DeviceType {
Self::Variant0
Self::Android
}
}
Loading
Loading