Skip to content

Commit a969b01

Browse files
committed
fix: Some list parameters were skipping the default list options
The Schema we were using for those classes was not mentioning default pagination attributes so they were never rendered. Issue: COR-4373
1 parent 0287061 commit a969b01

File tree

1 file changed

+12
-36
lines changed

1 file changed

+12
-36
lines changed

pygitguardian/models.py

Lines changed: 12 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,16 +1113,10 @@ class MembersParameters(PaginationParameter, SearchParameter, ToDictMixin):
11131113
] = None
11141114

11151115

1116-
class MembersParametersSchema(BaseSchema):
1117-
access_level = fields.Enum(AccessLevel, by_value=True, allow_none=True)
1118-
active = fields.Bool(allow_none=True)
1119-
ordering = fields.Str(allow_none=True)
1120-
1121-
@post_load
1122-
def make_members_parameters(self, data: Dict[str, Any], **kwargs: Any):
1123-
return MembersParameters(**data)
1124-
1125-
1116+
MembersParametersSchema = cast(
1117+
Type[BaseSchema],
1118+
marshmallow_dataclass.class_schema(MembersParameters, base_schema=BaseSchema),
1119+
)
11261120
MembersParameters.SCHEMA = MembersParametersSchema()
11271121

11281122

@@ -1298,17 +1292,10 @@ class TeamInvitationParameters(PaginationParameter, ToDictMixin):
12981292
incident_permission: Optional[IncidentPermission] = None
12991293

13001294

1301-
class TeamInvitationParameterSchema(BaseSchema):
1302-
invitation_id = fields.Int(allow_none=True)
1303-
is_team_leader = fields.Bool(allow_none=True)
1304-
incident_permission = fields.Enum(
1305-
IncidentPermission, by_value=True, allow_none=True
1306-
)
1307-
1308-
class Meta:
1309-
exclude_none = True
1310-
1311-
1295+
TeamInvitationParameterSchema = cast(
1296+
Type[BaseSchema],
1297+
marshmallow_dataclass.class_schema(TeamInvitationParameters, base_schema=BaseSchema),
1298+
)
13121299
TeamInvitationParameters.SCHEMA = TeamInvitationParameterSchema()
13131300

13141301

@@ -1374,21 +1361,10 @@ class TeamMemberParameters(PaginationParameter, SearchParameter, ToDictMixin):
13741361
member_id: Optional[int] = None
13751362

13761363

1377-
class TeamMembershipParameterSchema(BaseSchema):
1378-
is_team_leader = fields.Bool(allow_none=True)
1379-
incident_permission = fields.Enum(
1380-
IncidentPermission, by_value=True, allow_none=True
1381-
)
1382-
member_id = fields.Int(allow_none=True)
1383-
1384-
@post_load
1385-
def make_team_member_parameter(self, data: Dict[str, Any], **kwargs: Any):
1386-
return TeamMemberParameters(**data)
1387-
1388-
class Meta:
1389-
exclude_none = True
1390-
1391-
1364+
TeamMembershipParameterSchema = cast(
1365+
Type[BaseSchema],
1366+
marshmallow_dataclass.class_schema(TeamMemberParameters, base_schema=BaseSchema),
1367+
)
13921368
TeamMemberParameters.SCHEMA = TeamMembershipParameterSchema()
13931369

13941370

0 commit comments

Comments
 (0)