Skip to content

Commit 73bac7a

Browse files
feat!: update codegen with new fields and error codes (#23)
* don't format codegen * SDK updates * update get_app mock response * fix From impl --------- Co-authored-by: Bert Ramirez <[email protected]>
1 parent 070fd4a commit 73bac7a

Some content is hidden

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

57 files changed

+385
-315
lines changed

src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ impl From<crate::openapi::models::model_404_error::Model404Error> for Error {
170170
impl From<crate::openapi::models::model_409_error::Model409Error> for Error {
171171
fn from(e: crate::openapi::models::model_409_error::Model409Error) -> Self {
172172
match e.code {
173-
crate::openapi::models::model_409_error::Code::HasNoPasskeys => {
173+
crate::openapi::models::model_409_error::Code::UserHasNoPasskeys => {
174174
Error::UserHasNoPasskeys
175175
}
176176
_ => Error::Other(e.error),

src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ impl fmt::Display for Error {
5858

5959
mod error;
6060
pub mod models;
61+
62+
#[rustfmt::skip]
6163
pub mod openapi;
6264

6365
pub mod passage_flex;

src/openapi/apis/apps_api.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
* Generated by: https://openapi-generator.tech
99
*/
1010

11-
use super::{configuration, Error};
12-
use crate::openapi::{apis::ResponseContent, models};
11+
1312
use reqwest;
1413
use serde::{Deserialize, Serialize};
14+
use crate::openapi::{apis::ResponseContent, models};
15+
use super::{Error, configuration};
16+
1517

1618
/// struct for typed errors of method [`get_app`]
1719
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -23,21 +25,18 @@ pub enum GetAppError {
2325
UnknownValue(serde_json::Value),
2426
}
2527

28+
2629
/// Get app information.
27-
pub async fn get_app(
28-
configuration: &configuration::Configuration,
29-
) -> Result<models::AppResponse, Error<GetAppError>> {
30+
pub async fn get_app(configuration: &configuration::Configuration, ) -> Result<models::AppResponse, Error<GetAppError>> {
3031
let local_var_configuration = configuration;
3132

3233
let local_var_client = &local_var_configuration.client;
3334

3435
let local_var_uri_str = format!("{}/", local_var_configuration.base_path);
35-
let mut local_var_req_builder =
36-
local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
36+
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());
3737

3838
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
39-
local_var_req_builder =
40-
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
39+
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
4140
}
4241
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
4342
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
@@ -53,11 +52,8 @@ pub async fn get_app(
5352
serde_json::from_str(&local_var_content).map_err(Error::from)
5453
} else {
5554
let local_var_entity: Option<GetAppError> = serde_json::from_str(&local_var_content).ok();
56-
let local_var_error = ResponseContent {
57-
status: local_var_status,
58-
content: local_var_content,
59-
entity: local_var_entity,
60-
};
55+
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
6156
Err(Error::ResponseError(local_var_error))
6257
}
6358
}
59+

src/openapi/apis/authenticate_api.rs

+11-17
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
* Generated by: https://openapi-generator.tech
99
*/
1010

11-
use super::{configuration, Error};
12-
use crate::openapi::{apis::ResponseContent, models};
11+
1312
use reqwest;
1413
use serde::{Deserialize, Serialize};
14+
use crate::openapi::{apis::ResponseContent, models};
15+
use super::{Error, configuration};
16+
1517

1618
/// struct for typed errors of method [`authenticate_verify_nonce`]
1719
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -25,22 +27,18 @@ pub enum AuthenticateVerifyNonceError {
2527
UnknownValue(serde_json::Value),
2628
}
2729

30+
2831
/// Verify the nonce received from a WebAuthn registration or authentication ceremony. This endpoint checks that the nonce for the given application is valid, then returns a success or error message to the caller.
29-
pub async fn authenticate_verify_nonce(
30-
configuration: &configuration::Configuration,
31-
body: models::Nonce,
32-
) -> Result<models::AuthenticateVerifyNonceResponse, Error<AuthenticateVerifyNonceError>> {
32+
pub async fn authenticate_verify_nonce(configuration: &configuration::Configuration, body: models::Nonce) -> Result<models::AuthenticateVerifyNonceResponse, Error<AuthenticateVerifyNonceError>> {
3333
let local_var_configuration = configuration;
3434

3535
let local_var_client = &local_var_configuration.client;
3636

3737
let local_var_uri_str = format!("{}/authenticate/verify", local_var_configuration.base_path);
38-
let mut local_var_req_builder =
39-
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
38+
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
4039

4140
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
42-
local_var_req_builder =
43-
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
41+
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
4442
}
4543
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
4644
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
@@ -56,13 +54,9 @@ pub async fn authenticate_verify_nonce(
5654
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
5755
serde_json::from_str(&local_var_content).map_err(Error::from)
5856
} else {
59-
let local_var_entity: Option<AuthenticateVerifyNonceError> =
60-
serde_json::from_str(&local_var_content).ok();
61-
let local_var_error = ResponseContent {
62-
status: local_var_status,
63-
content: local_var_content,
64-
entity: local_var_entity,
65-
};
57+
let local_var_entity: Option<AuthenticateVerifyNonceError> = serde_json::from_str(&local_var_content).ok();
58+
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
6659
Err(Error::ResponseError(local_var_error))
6760
}
6861
}
62+

src/openapi/apis/configuration.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* Generated by: https://openapi-generator.tech
99
*/
1010

11+
12+
1113
#[derive(Debug, Clone)]
1214
pub struct Configuration {
1315
pub base_path: String,
@@ -17,7 +19,6 @@ pub struct Configuration {
1719
pub oauth_access_token: Option<String>,
1820
pub bearer_access_token: Option<String>,
1921
pub api_key: Option<ApiKey>,
20-
// TODO: take an oauth2 token source, similar to the go one
2122
}
2223

2324
pub type BasicAuth = (String, Option<String>);
@@ -28,6 +29,7 @@ pub struct ApiKey {
2829
pub key: String,
2930
}
3031

32+
3133
impl Configuration {
3234
pub fn new() -> Configuration {
3335
Configuration::default()

src/openapi/apis/mod.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub enum Error<T> {
1616
ResponseError(ResponseContent<T>),
1717
}
1818

19-
impl<T> fmt::Display for Error<T> {
19+
impl <T> fmt::Display for Error<T> {
2020
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
2121
let (module, e) = match self {
2222
Error::Reqwest(e) => ("reqwest", e.to_string()),
@@ -28,7 +28,7 @@ impl<T> fmt::Display for Error<T> {
2828
}
2929
}
3030

31-
impl<T: fmt::Debug> error::Error for Error<T> {
31+
impl <T: fmt::Debug> error::Error for Error<T> {
3232
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
3333
Some(match self {
3434
Error::Reqwest(e) => e,
@@ -39,19 +39,19 @@ impl<T: fmt::Debug> error::Error for Error<T> {
3939
}
4040
}
4141

42-
impl<T> From<reqwest::Error> for Error<T> {
42+
impl <T> From<reqwest::Error> for Error<T> {
4343
fn from(e: reqwest::Error) -> Self {
4444
Error::Reqwest(e)
4545
}
4646
}
4747

48-
impl<T> From<serde_json::Error> for Error<T> {
48+
impl <T> From<serde_json::Error> for Error<T> {
4949
fn from(e: serde_json::Error) -> Self {
5050
Error::Serde(e)
5151
}
5252
}
5353

54-
impl<T> From<std::io::Error> for Error<T> {
54+
impl <T> From<std::io::Error> for Error<T> {
5555
fn from(e: std::io::Error) -> Self {
5656
Error::Io(e)
5757
}
@@ -78,10 +78,8 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
7878
value,
7979
));
8080
}
81-
}
82-
serde_json::Value::String(s) => {
83-
params.push((format!("{}[{}]", prefix, key), s.clone()))
84-
}
81+
},
82+
serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())),
8583
_ => params.push((format!("{}[{}]", prefix, key), value.to_string())),
8684
}
8785
}

src/openapi/apis/transactions_api.rs

+18-40
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
* Generated by: https://openapi-generator.tech
99
*/
1010

11-
use super::{configuration, Error};
12-
use crate::openapi::{apis::ResponseContent, models};
11+
1312
use reqwest;
1413
use serde::{Deserialize, Serialize};
14+
use crate::openapi::{apis::ResponseContent, models};
15+
use super::{Error, configuration};
16+
1517

1618
/// struct for typed errors of method [`create_authenticate_transaction`]
1719
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -38,24 +40,17 @@ pub enum CreateRegisterTransactionError {
3840
UnknownValue(serde_json::Value),
3941
}
4042

41-
pub async fn create_authenticate_transaction(
42-
configuration: &configuration::Configuration,
43-
create_transaction_authenticate_request: models::CreateTransactionAuthenticateRequest,
44-
) -> Result<models::CreateTransactionResponse, Error<CreateAuthenticateTransactionError>> {
43+
44+
pub async fn create_authenticate_transaction(configuration: &configuration::Configuration, create_transaction_authenticate_request: models::CreateTransactionAuthenticateRequest) -> Result<models::CreateTransactionResponse, Error<CreateAuthenticateTransactionError>> {
4545
let local_var_configuration = configuration;
4646

4747
let local_var_client = &local_var_configuration.client;
4848

49-
let local_var_uri_str = format!(
50-
"{}/transactions/authenticate",
51-
local_var_configuration.base_path
52-
);
53-
let mut local_var_req_builder =
54-
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
49+
let local_var_uri_str = format!("{}/transactions/authenticate", local_var_configuration.base_path);
50+
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
5551

5652
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
57-
local_var_req_builder =
58-
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
53+
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
5954
}
6055
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
6156
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
@@ -71,35 +66,22 @@ pub async fn create_authenticate_transaction(
7166
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
7267
serde_json::from_str(&local_var_content).map_err(Error::from)
7368
} else {
74-
let local_var_entity: Option<CreateAuthenticateTransactionError> =
75-
serde_json::from_str(&local_var_content).ok();
76-
let local_var_error = ResponseContent {
77-
status: local_var_status,
78-
content: local_var_content,
79-
entity: local_var_entity,
80-
};
69+
let local_var_entity: Option<CreateAuthenticateTransactionError> = serde_json::from_str(&local_var_content).ok();
70+
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
8171
Err(Error::ResponseError(local_var_error))
8272
}
8373
}
8474

85-
pub async fn create_register_transaction(
86-
configuration: &configuration::Configuration,
87-
create_transaction_register_request: models::CreateTransactionRegisterRequest,
88-
) -> Result<models::CreateTransactionResponse, Error<CreateRegisterTransactionError>> {
75+
pub async fn create_register_transaction(configuration: &configuration::Configuration, create_transaction_register_request: models::CreateTransactionRegisterRequest) -> Result<models::CreateTransactionResponse, Error<CreateRegisterTransactionError>> {
8976
let local_var_configuration = configuration;
9077

9178
let local_var_client = &local_var_configuration.client;
9279

93-
let local_var_uri_str = format!(
94-
"{}/transactions/register",
95-
local_var_configuration.base_path
96-
);
97-
let mut local_var_req_builder =
98-
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
80+
let local_var_uri_str = format!("{}/transactions/register", local_var_configuration.base_path);
81+
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
9982

10083
if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
101-
local_var_req_builder =
102-
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
84+
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
10385
}
10486
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
10587
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
@@ -115,13 +97,9 @@ pub async fn create_register_transaction(
11597
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
11698
serde_json::from_str(&local_var_content).map_err(Error::from)
11799
} else {
118-
let local_var_entity: Option<CreateRegisterTransactionError> =
119-
serde_json::from_str(&local_var_content).ok();
120-
let local_var_error = ResponseContent {
121-
status: local_var_status,
122-
content: local_var_content,
123-
entity: local_var_entity,
124-
};
100+
let local_var_entity: Option<CreateRegisterTransactionError> = serde_json::from_str(&local_var_content).ok();
101+
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
125102
Err(Error::ResponseError(local_var_error))
126103
}
127104
}
105+

0 commit comments

Comments
 (0)