Skip to content

Commit

Permalink
Set validator to None empty listed assignees or reviewers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Knucklessg1 committed Jul 30, 2024
1 parent b121ce7 commit c5bc95c
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions gitlab_api/gitlab_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"
)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c5bc95c

Please sign in to comment.