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

feat!: update codegen with new fields and error codes #23

Merged
merged 4 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ impl From<crate::openapi::models::model_404_error::Model404Error> for Error {
impl From<crate::openapi::models::model_409_error::Model409Error> for Error {
fn from(e: crate::openapi::models::model_409_error::Model409Error) -> Self {
match e.code {
crate::openapi::models::model_409_error::Code::HasNoPasskeys => {
crate::openapi::models::model_409_error::Code::UserHasNoPasskeys => {
Error::UserHasNoPasskeys
}
_ => Error::Other(e.error),
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ impl fmt::Display for Error {

mod error;
pub mod models;

#[rustfmt::skip]
pub mod openapi;

pub mod passage_flex;
Expand Down
24 changes: 10 additions & 14 deletions src/openapi/apis/apps_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
* Generated by: https://openapi-generator.tech
*/

use super::{configuration, Error};
use crate::openapi::{apis::ResponseContent, models};

use reqwest;
use serde::{Deserialize, Serialize};
use crate::openapi::{apis::ResponseContent, models};
use super::{Error, configuration};


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


/// Get app information.
pub async fn get_app(
configuration: &configuration::Configuration,
) -> Result<models::AppResponse, Error<GetAppError>> {
pub async fn get_app(configuration: &configuration::Configuration, ) -> Result<models::AppResponse, Error<GetAppError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

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

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
Expand All @@ -53,11 +52,8 @@ pub async fn get_app(
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<GetAppError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

28 changes: 11 additions & 17 deletions src/openapi/apis/authenticate_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
* Generated by: https://openapi-generator.tech
*/

use super::{configuration, Error};
use crate::openapi::{apis::ResponseContent, models};

use reqwest;
use serde::{Deserialize, Serialize};
use crate::openapi::{apis::ResponseContent, models};
use super::{Error, configuration};


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


/// 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.
pub async fn authenticate_verify_nonce(
configuration: &configuration::Configuration,
body: models::Nonce,
) -> Result<models::AuthenticateVerifyNonceResponse, Error<AuthenticateVerifyNonceError>> {
pub async fn authenticate_verify_nonce(configuration: &configuration::Configuration, body: models::Nonce) -> Result<models::AuthenticateVerifyNonceResponse, Error<AuthenticateVerifyNonceError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

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

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
Expand All @@ -56,13 +54,9 @@ pub async fn authenticate_verify_nonce(
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AuthenticateVerifyNonceError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
let local_var_entity: Option<AuthenticateVerifyNonceError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

4 changes: 3 additions & 1 deletion src/openapi/apis/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* Generated by: https://openapi-generator.tech
*/



#[derive(Debug, Clone)]
pub struct Configuration {
pub base_path: String,
Expand All @@ -17,7 +19,6 @@ pub struct Configuration {
pub oauth_access_token: Option<String>,
pub bearer_access_token: Option<String>,
pub api_key: Option<ApiKey>,
// TODO: take an oauth2 token source, similar to the go one
}

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


impl Configuration {
pub fn new() -> Configuration {
Configuration::default()
Expand Down
16 changes: 7 additions & 9 deletions src/openapi/apis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum Error<T> {
ResponseError(ResponseContent<T>),
}

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

impl<T: fmt::Debug> error::Error for Error<T> {
impl <T: fmt::Debug> error::Error for Error<T> {
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
Some(match self {
Error::Reqwest(e) => e,
Expand All @@ -39,19 +39,19 @@ impl<T: fmt::Debug> error::Error for Error<T> {
}
}

impl<T> From<reqwest::Error> for Error<T> {
impl <T> From<reqwest::Error> for Error<T> {
fn from(e: reqwest::Error) -> Self {
Error::Reqwest(e)
}
}

impl<T> From<serde_json::Error> for Error<T> {
impl <T> From<serde_json::Error> for Error<T> {
fn from(e: serde_json::Error) -> Self {
Error::Serde(e)
}
}

impl<T> From<std::io::Error> for Error<T> {
impl <T> From<std::io::Error> for Error<T> {
fn from(e: std::io::Error) -> Self {
Error::Io(e)
}
Expand All @@ -78,10 +78,8 @@ pub fn parse_deep_object(prefix: &str, value: &serde_json::Value) -> Vec<(String
value,
));
}
}
serde_json::Value::String(s) => {
params.push((format!("{}[{}]", prefix, key), s.clone()))
}
},
serde_json::Value::String(s) => params.push((format!("{}[{}]", prefix, key), s.clone())),
_ => params.push((format!("{}[{}]", prefix, key), value.to_string())),
}
}
Expand Down
58 changes: 18 additions & 40 deletions src/openapi/apis/transactions_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
* Generated by: https://openapi-generator.tech
*/

use super::{configuration, Error};
use crate::openapi::{apis::ResponseContent, models};

use reqwest;
use serde::{Deserialize, Serialize};
use crate::openapi::{apis::ResponseContent, models};
use super::{Error, configuration};


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

pub async fn create_authenticate_transaction(
configuration: &configuration::Configuration,
create_transaction_authenticate_request: models::CreateTransactionAuthenticateRequest,
) -> Result<models::CreateTransactionResponse, Error<CreateAuthenticateTransactionError>> {

pub async fn create_authenticate_transaction(configuration: &configuration::Configuration, create_transaction_authenticate_request: models::CreateTransactionAuthenticateRequest) -> Result<models::CreateTransactionResponse, Error<CreateAuthenticateTransactionError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!(
"{}/transactions/authenticate",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
let local_var_uri_str = format!("{}/transactions/authenticate", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
Expand All @@ -71,35 +66,22 @@ pub async fn create_authenticate_transaction(
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateAuthenticateTransactionError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
let local_var_entity: Option<CreateAuthenticateTransactionError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

pub async fn create_register_transaction(
configuration: &configuration::Configuration,
create_transaction_register_request: models::CreateTransactionRegisterRequest,
) -> Result<models::CreateTransactionResponse, Error<CreateRegisterTransactionError>> {
pub async fn create_register_transaction(configuration: &configuration::Configuration, create_transaction_register_request: models::CreateTransactionRegisterRequest) -> Result<models::CreateTransactionResponse, Error<CreateRegisterTransactionError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!(
"{}/transactions/register",
local_var_configuration.base_path
);
let mut local_var_req_builder =
local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());
let local_var_uri_str = format!("{}/transactions/register", local_var_configuration.base_path);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
local_var_req_builder =
local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone());
}
if let Some(ref local_var_token) = local_var_configuration.bearer_access_token {
local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned());
Expand All @@ -115,13 +97,9 @@ pub async fn create_register_transaction(
if !local_var_status.is_client_error() && !local_var_status.is_server_error() {
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<CreateRegisterTransactionError> =
serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
let local_var_entity: Option<CreateRegisterTransactionError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
Err(Error::ResponseError(local_var_error))
}
}

Loading
Loading