Skip to content

Commit

Permalink
fix: id in create endpoints payload (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulkr authored Aug 20, 2024
1 parent eaf0643 commit 5389ffd
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 19 deletions.
5 changes: 3 additions & 2 deletions integrationos-api/src/logic/common_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ pub fn get_router() -> Router<Arc<AppState>> {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[serde(rename_all = "camelCase")]
pub struct CreateRequest {
pub _id: Option<Id>,
#[serde(rename = "_id")]
pub id: Option<Id>,
pub name: String,
pub version: Version,
pub fields: Vec<Field>,
Expand Down Expand Up @@ -81,7 +82,7 @@ impl RequestExt for CreateRequest {

fn from(&self) -> Option<Self::Output> {
let mut record = Self::Output {
id: self._id.unwrap_or_else(|| Id::now(IdPrefix::CommonModel)),
id: self.id.unwrap_or_else(|| Id::now(IdPrefix::CommonModel)),
name: self.name.clone(),
fields: self.fields.clone(),
sample: self.sample.clone(),
Expand Down
5 changes: 3 additions & 2 deletions integrationos-api/src/logic/connection_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ pub fn get_router() -> Router<Arc<AppState>> {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[serde(rename_all = "camelCase")]
pub struct CreateRequest {
pub _id: Option<Id>,
#[serde(rename = "_id")]
pub id: Option<Id>,
pub platform: String,
pub platform_version: String,
#[serde(default)]
Expand Down Expand Up @@ -324,7 +325,7 @@ impl RequestExt for CreateRequest {

let mut record = Self::Output {
id: self
._id
.id
.unwrap_or_else(|| Id::now(IdPrefix::ConnectionDefinition)),
platform_version: self.platform_version.clone(),
platform: self.platform.clone(),
Expand Down
5 changes: 3 additions & 2 deletions integrationos-api/src/logic/connection_model_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ pub async fn test_connection_model_definition(
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[serde(rename_all = "camelCase")]
pub struct CreateRequest {
pub _id: Option<Id>,
#[serde(rename = "_id")]
pub id: Option<Id>,
pub connection_platform: String,
pub connection_definition_id: Id,
pub platform_version: String,
Expand Down Expand Up @@ -328,7 +329,7 @@ impl RequestExt for CreateRequest {

let mut record = Self::Output {
id: self
._id
.id
.unwrap_or_else(|| Id::now(IdPrefix::ConnectionModelDefinition)),
connection_platform: self.connection_platform.clone(),
connection_definition_id: self.connection_definition_id,
Expand Down
5 changes: 3 additions & 2 deletions integrationos-api/src/logic/connection_model_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ pub async fn get_platform_models(
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[serde(rename_all = "camelCase")]
pub struct CreateRequest {
pub _id: Option<Id>,
#[serde(rename = "_id")]
pub id: Option<Id>,
pub platform_id: Id,
pub platform_page_id: Id,
pub connection_platform: String,
Expand Down Expand Up @@ -179,7 +180,7 @@ impl RequestExt for CreateRequest {

Some(Self::Output {
id: self
._id
.id
.unwrap_or_else(|| Id::now(IdPrefix::ConnectionModelSchema)),
platform_id: self.platform_id,
platform_page_id: self.platform_page_id,
Expand Down
5 changes: 3 additions & 2 deletions integrationos-api/src/logic/connection_oauth_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ pub fn get_router() -> Router<Arc<AppState>> {
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateRequest {
pub _id: Option<Id>,
#[serde(rename = "_id")]
pub id: Option<Id>,
pub connection_platform: String,
pub platform_redirect_uri: String,
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -71,7 +72,7 @@ impl RequestExt for CreateRequest {
fn from(&self) -> Option<Self::Output> {
Some(Self::Output {
id: self
._id
.id
.unwrap_or_else(|| Id::now(IdPrefix::ConnectionOAuthDefinition)),
connection_platform: self.connection_platform.clone(),
configuration: OAuthApiConfig {
Expand Down
5 changes: 3 additions & 2 deletions integrationos-api/src/logic/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ pub fn get_router() -> Router<Arc<AppState>> {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[serde(rename_all = "camelCase")]
pub struct CreateRequest {
pub _id: Option<Id>,
#[serde(rename = "_id")]
pub id: Option<Id>,
pub connection_definition_id: Id,
pub name: String,
pub url: String,
Expand All @@ -48,7 +49,7 @@ impl RequestExt for CreateRequest {

fn from(&self) -> Option<Self::Output> {
Some(Self::Output {
id: self._id.unwrap_or_else(|| Id::now(IdPrefix::Platform)),
id: self.id.unwrap_or_else(|| Id::now(IdPrefix::Platform)),
connection_definition_id: self.connection_definition_id,
name: self.name.clone(),
url: self.url.clone(),
Expand Down
5 changes: 3 additions & 2 deletions integrationos-api/src/logic/platform_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ pub fn get_router() -> Router<Arc<AppState>> {
#[cfg_attr(feature = "dummy", derive(fake::Dummy))]
#[serde(rename_all = "camelCase")]
pub struct CreateRequest {
pub _id: Option<Id>,
#[serde(rename = "_id")]
pub id: Option<Id>,
pub platform_id: Id,
pub connection_definition_id: Id,
pub platform_name: String,
Expand Down Expand Up @@ -106,7 +107,7 @@ impl RequestExt for CreateRequest {
let hashed = HashedSecret::try_from(hash_value).ok()?;

Some(Self::Output {
id: self._id.unwrap_or_else(|| Id::now(IdPrefix::PlatformPage)),
id: self.id.unwrap_or_else(|| Id::now(IdPrefix::PlatformPage)),
platform_id: self.platform_id,
platform_name: self.platform_name.clone(),
connection_definition_id: self.connection_definition_id,
Expand Down
4 changes: 2 additions & 2 deletions integrationos-api/tests/api_tests/get_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async fn test_get_expanded_common_model() {
let reference: String = Faker.fake();

let base = common_model::CreateRequest {
_id: None,
id: None,
name: Faker.fake(),
version: Faker.fake(),
fields: vec![
Expand Down Expand Up @@ -73,7 +73,7 @@ async fn test_get_expanded_common_model() {
};

let expandable = common_model::CreateRequest {
_id: None,
id: None,
name: reference.clone(),
version: Faker.fake(),
fields: vec![],
Expand Down
2 changes: 1 addition & 1 deletion integrationos-api/tests/api_tests/passthrough_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async fn test_passthrough_api() {
.create();

let create_model_definition_payload = CreateConnectionModelDefinitionRequest {
_id: None,
id: None,
connection_platform: connection.platform.to_string(),
connection_definition_id: conn_def.id,
platform_version: conn_def.record_metadata.version.to_string(),
Expand Down
2 changes: 1 addition & 1 deletion integrationos-api/tests/api_tests/test_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ impl TestServer {
assert!(!connection.secrets_service_id.is_empty());

let model_def = CreateConnectionModelDefinitionRequest {
_id: None,
id: None,
connection_platform: connection_def.platform,
connection_definition_id: connection_def.id,
platform_version: connection_def.platform_version,
Expand Down
2 changes: 1 addition & 1 deletion integrationos-api/tests/api_tests/unified_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ async fn create_connection_model_definition(
.await;

let create_model_definition_payload = CreateConnectionModelDefinitionRequest {
_id: None,
id: None,
connection_platform: connection.platform.to_string(),
connection_definition_id: connection.connection_definition_id,
platform_version: connection.record_metadata.version.to_string(),
Expand Down

0 comments on commit 5389ffd

Please sign in to comment.