diff --git a/gitlab_api/gitlab_models.py b/gitlab_api/gitlab_models.py index 786d434..1526a75 100644 --- a/gitlab_api/gitlab_models.py +++ b/gitlab_api/gitlab_models.py @@ -4943,6 +4943,12 @@ class Meta: default=None, description="List of users who approved" ) + @field_validator('eligible_approvers', 'users', 'approved_by', mode='before') + def empty_list_to_none(cls, v): + if isinstance(v, list) and not v: + return None + return v + class ApprovalRules(BaseModel): model_config = ConfigDict(extra="forbid") @@ -5120,9 +5126,6 @@ class Meta: tag_list: Optional[List[str]] = Field( default=None, description="List of tags associated with the merge request" ) - reviewer: Optional[Users] = Field( - default=None, description="List of reviewers for the merge request" - ) review: Optional[Dict[str, Any]] = Field( default=None, description="Review information associated with the merge request" ) @@ -5176,6 +5179,12 @@ class Meta: default=None, description="List of merge request rules" ) + @field_validator('assignees', 'reviewers', mode='before') + def empty_list_to_none(cls, v): + if isinstance(v, list) and not v: + return None + return v + class MergeRequests(BaseModel): model_config = ConfigDict(extra="forbid") @@ -5336,6 +5345,12 @@ class Meta: default=None, description="Blocking issue count." ) + @field_validator('assignees', mode='before') + def empty_list_to_none(cls, v): + if isinstance(v, list) and not v: + return None + return v + class Issues(BaseModel): model_config = ConfigDict(extra="forbid") @@ -5526,6 +5541,12 @@ class Meta: default=None, description="Whether a password is required to approve" ) + @field_validator('approvers', mode='before') + def empty_list_to_none(cls, v): + if isinstance(v, list) and not v: + return None + return v + class DeployToken(BaseModel): class Meta: