From 4211b2b3b779a28b9e0d6091dbb4bffaab422cb3 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Wed, 6 May 2026 11:36:51 +0100 Subject: [PATCH 1/2] Add parameters to group show API Co-authored-by: Stephan Vock <442056+glaubinix@users.noreply.github.com> --- CHANGELOG.md | 1 + src/Api/Groups.php | 25 +++++++++++++++++++++++-- tests/Api/GroupsTest.php | 16 ++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66e7f104..8f59ee3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Add support for `without_project_bots` in `Users::all` * Add support for date filters and `finished_at` ordering in `Deployments::all` * Add support for listing merge requests associated with a deployment +* Add support for `with_custom_attributes` and `with_projects` in `Groups::show` ## [12.0.0] - 2025-02-23 diff --git a/src/Api/Groups.php b/src/Api/Groups.php index f592422d..7c3b624a 100644 --- a/src/Api/Groups.php +++ b/src/Api/Groups.php @@ -68,9 +68,30 @@ public function all(array $parameters = []): mixed return $this->get('groups', $resolver->resolve($parameters)); } - public function show(int|string $id): mixed + /** + * @param array $parameters { + * + * @var bool $with_custom_attributes Include custom attributes in response. + * @var bool $with_projects Include details from projects that belong to the group. + * } + */ + public function show(int|string $id, array $parameters = []): mixed { - return $this->get('groups/'.self::encodePath($id)); + $resolver = $this->createOptionsResolver(); + $booleanNormalizer = function (Options $resolver, $value): string { + return $value ? 'true' : 'false'; + }; + + $resolver->setDefined('with_custom_attributes') + ->setAllowedTypes('with_custom_attributes', 'bool') + ->setNormalizer('with_custom_attributes', $booleanNormalizer) + ; + $resolver->setDefined('with_projects') + ->setAllowedTypes('with_projects', 'bool') + ->setNormalizer('with_projects', $booleanNormalizer) + ; + + return $this->get('groups/'.self::encodePath($id), $resolver->resolve($parameters)); } public function create(string $name, string $path, ?string $description = null, string $visibility = 'private', ?bool $lfs_enabled = null, ?bool $request_access_enabled = null, ?int $parent_id = null, ?int $shared_runners_minutes_limit = null): mixed diff --git a/tests/Api/GroupsTest.php b/tests/Api/GroupsTest.php index 05a54e03..3bd2c7df 100644 --- a/tests/Api/GroupsTest.php +++ b/tests/Api/GroupsTest.php @@ -143,6 +143,22 @@ public function shouldShowGroup(): void $this->assertEquals($expectedArray, $api->show(1)); } + #[Test] + public function shouldShowGroupWithAdditionalParameters(): void + { + $expectedArray = ['id' => 1, 'name' => 'A group']; + $parameters = ['with_custom_attributes' => true, 'with_projects' => false]; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get') + ->with('groups/1', ['with_custom_attributes' => 'true', 'with_projects' => 'false']) + ->willReturn($expectedArray) + ; + + $this->assertEquals($expectedArray, $api->show(1, $parameters)); + } + #[Test] public function shouldCreateGroup(): void { From 3a7fc7e15e8d4c394598dc62c3b4f04916237261 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Wed, 6 May 2026 10:38:04 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- src/Api/Groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/Groups.php b/src/Api/Groups.php index 7c3b624a..5248e36e 100644 --- a/src/Api/Groups.php +++ b/src/Api/Groups.php @@ -71,7 +71,7 @@ public function all(array $parameters = []): mixed /** * @param array $parameters { * - * @var bool $with_custom_attributes Include custom attributes in response. + * @var bool $with_custom_attributes include custom attributes in response * @var bool $with_projects Include details from projects that belong to the group. * } */