From 4843a893163f6cb18af0f12ff308e27f7606001d Mon Sep 17 00:00:00 2001 From: gtema Date: Tue, 16 Sep 2025 19:03:49 +0200 Subject: [PATCH] chore: Fine tune mapping schema for the generator To further support codegenerator (sdk/cli/tui) further minor changes to the openapi schema interpretation are necessary. --- src/api/v4/federation/mapping/create.rs | 2 +- src/api/v4/federation/mapping/delete.rs | 2 +- src/api/v4/federation/mapping/list.rs | 2 +- src/api/v4/federation/mapping/show.rs | 2 +- src/api/v4/federation/mapping/update.rs | 2 +- src/api/v4/federation/types/identity_provider.rs | 2 ++ src/api/v4/federation/types/mapping.rs | 10 +++++++++- 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/api/v4/federation/mapping/create.rs b/src/api/v4/federation/mapping/create.rs index 439a6fe7..2f26ab09 100644 --- a/src/api/v4/federation/mapping/create.rs +++ b/src/api/v4/federation/mapping/create.rs @@ -28,7 +28,7 @@ use crate::policy::Policy; #[utoipa::path( post, path = "/", - operation_id = "/federation/identity_provider/mapping:create", + operation_id = "/federation/mapping:create", responses( (status = CREATED, description = "mapping object", body = MappingResponse), ), diff --git a/src/api/v4/federation/mapping/delete.rs b/src/api/v4/federation/mapping/delete.rs index 7e4a1a98..88007332 100644 --- a/src/api/v4/federation/mapping/delete.rs +++ b/src/api/v4/federation/mapping/delete.rs @@ -31,7 +31,7 @@ use crate::policy::Policy; #[utoipa::path( delete, path = "/{id}", - operation_id = "/federation/identity_provider/mapping:delete", + operation_id = "/federation/mapping:delete", params( ("id" = String, Path, description = "The ID of the attribute mapping") ), diff --git a/src/api/v4/federation/mapping/list.rs b/src/api/v4/federation/mapping/list.rs index 3338b39f..3021afc9 100644 --- a/src/api/v4/federation/mapping/list.rs +++ b/src/api/v4/federation/mapping/list.rs @@ -39,7 +39,7 @@ use crate::policy::Policy; #[utoipa::path( get, path = "/", - operation_id = "/federation/identity_provider/mapping:list", + operation_id = "/federation/mapping:list", params(MappingListParameters), responses( (status = OK, description = "List of mappings", body = MappingList), diff --git a/src/api/v4/federation/mapping/show.rs b/src/api/v4/federation/mapping/show.rs index d3632993..27981d8b 100644 --- a/src/api/v4/federation/mapping/show.rs +++ b/src/api/v4/federation/mapping/show.rs @@ -33,7 +33,7 @@ use crate::policy::Policy; #[utoipa::path( get, path = "/{id}", - operation_id = "/federation/identity_provider/mapping:show", + operation_id = "/federation/mapping:show", params( ("id" = String, Path, description = "The ID of the attribute mapping.") ), diff --git a/src/api/v4/federation/mapping/update.rs b/src/api/v4/federation/mapping/update.rs index 281dded9..eaa38810 100644 --- a/src/api/v4/federation/mapping/update.rs +++ b/src/api/v4/federation/mapping/update.rs @@ -34,7 +34,7 @@ use crate::policy::Policy; #[utoipa::path( put, path = "/{id}", - operation_id = "/federation/identity_provider/mapping:update", + operation_id = "/federation/mapping:update", params( ("id" = String, Path, description = "The ID of the attribute mapping.") ), diff --git a/src/api/v4/federation/types/identity_provider.rs b/src/api/v4/federation/types/identity_provider.rs index f7f5a4a4..8ed93066 100644 --- a/src/api/v4/federation/types/identity_provider.rs +++ b/src/api/v4/federation/types/identity_provider.rs @@ -337,9 +337,11 @@ impl IntoResponse for IdentityProviderList { #[derive(Clone, Debug, Default, Deserialize, Serialize, IntoParams)] pub struct IdentityProviderListParameters { /// Filters the response by IDP name. + #[param(nullable = false)] pub name: Option, /// Filters the response by a domain ID. + #[param(nullable = false)] pub domain_id: Option, } diff --git a/src/api/v4/federation/types/mapping.rs b/src/api/v4/federation/types/mapping.rs index 5dc86ea6..8ee16c1c 100644 --- a/src/api/v4/federation/types/mapping.rs +++ b/src/api/v4/federation/types/mapping.rs @@ -86,6 +86,7 @@ pub struct Mapping { /// Additional claims that must be present in the token. #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] + #[schema(value_type = Object)] pub bound_claims: Option, /// List of OIDC scopes. @@ -184,7 +185,7 @@ pub struct MappingCreate { /// Additional claims that must be present in the token. #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] - #[schema(nullable = false)] + #[schema(nullable = false, value_type = Object)] pub bound_claims: Option, /// List of OIDC scopes. @@ -236,6 +237,8 @@ pub struct MappingUpdate { /// Attribute mapping type ([oidc, jwt]). #[builder(default)] + #[serde(skip_serializing_if = "Option::is_none")] + #[schema(nullable = false)] pub r#type: Option, /// List of allowed redirect urls (only for `oidc` type). @@ -275,6 +278,7 @@ pub struct MappingUpdate { /// Additional claims that must be present in the token. #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] + #[schema(nullable = false, value_type = Object)] pub bound_claims: Option, /// List of OIDC scopes. @@ -448,15 +452,19 @@ impl IntoResponse for MappingList { #[derive(Clone, Debug, Default, Deserialize, Serialize, IntoParams)] pub struct MappingListParameters { /// Filters the response by IDP name. + #[param(nullable = false)] pub name: Option, /// Filters the response by a domain ID. + #[param(nullable = false)] pub domain_id: Option, /// Filters the response by a idp ID. + #[param(nullable = false)] pub idp_id: Option, /// Filters the response by a mapping type. + #[param(nullable = false)] pub r#type: Option, }