feat: add OpenAPI doc for update_profile_fields endpoint
Add ProfileFieldDto and UpdateProfileFieldsRequest to api-types, annotate update_profile_fields_handler with utoipa::path, register in UsersDoc. Coverage now 100%.
This commit is contained in:
@@ -83,3 +83,14 @@ pub struct ProfileResponse {
|
|||||||
pub bio: Option<String>,
|
pub bio: Option<String>,
|
||||||
pub avatar_url: Option<String>,
|
pub avatar_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
|
||||||
|
pub struct ProfileFieldDto {
|
||||||
|
pub name: String,
|
||||||
|
pub value: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
|
||||||
|
pub struct UpdateProfileFieldsRequest {
|
||||||
|
pub fields: Vec<ProfileFieldDto>,
|
||||||
|
}
|
||||||
|
|||||||
@@ -540,6 +540,17 @@ pub async fn update_profile_handler(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[utoipa::path(
|
||||||
|
put, path = "/api/v1/profile/fields",
|
||||||
|
request_body = api_types::UpdateProfileFieldsRequest,
|
||||||
|
responses(
|
||||||
|
(status = 204, description = "Profile fields updated"),
|
||||||
|
(status = 400, description = "Invalid input"),
|
||||||
|
(status = 401, description = "Unauthorized"),
|
||||||
|
(status = 500, description = "Internal server error"),
|
||||||
|
),
|
||||||
|
security(("bearer_auth" = []))
|
||||||
|
)]
|
||||||
pub async fn update_profile_fields_handler(
|
pub async fn update_profile_fields_handler(
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
AuthenticatedUser(user_id): AuthenticatedUser,
|
AuthenticatedUser(user_id): AuthenticatedUser,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use api_types::{
|
use api_types::{
|
||||||
ProfileResponse, UserProfileResponse, UserStatsDto, UserSummaryDto, UsersResponse,
|
ProfileFieldDto, ProfileResponse, UpdateProfileFieldsRequest, UserProfileResponse,
|
||||||
|
UserStatsDto, UserSummaryDto, UsersResponse,
|
||||||
};
|
};
|
||||||
use utoipa::OpenApi;
|
use utoipa::OpenApi;
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ use utoipa::OpenApi;
|
|||||||
crate::handlers::api::get_user_profile,
|
crate::handlers::api::get_user_profile,
|
||||||
crate::handlers::api::get_profile,
|
crate::handlers::api::get_profile,
|
||||||
crate::handlers::api::update_profile_handler,
|
crate::handlers::api::update_profile_handler,
|
||||||
|
crate::handlers::api::update_profile_fields_handler,
|
||||||
),
|
),
|
||||||
components(schemas(
|
components(schemas(
|
||||||
UsersResponse,
|
UsersResponse,
|
||||||
@@ -17,6 +19,8 @@ use utoipa::OpenApi;
|
|||||||
UserProfileResponse,
|
UserProfileResponse,
|
||||||
UserStatsDto,
|
UserStatsDto,
|
||||||
ProfileResponse,
|
ProfileResponse,
|
||||||
|
UpdateProfileFieldsRequest,
|
||||||
|
ProfileFieldDto,
|
||||||
))
|
))
|
||||||
)]
|
)]
|
||||||
pub struct UsersDoc;
|
pub struct UsersDoc;
|
||||||
|
|||||||
Reference in New Issue
Block a user