Skip to content

Commit 13edfc3

Browse files
authored
Merge pull request #755 from php-api-clients/GitHub/from-1.1.4-cdf06887872e14c33e252a1a6bb7b705-from-1.1.4-cdf06887872e14c33e252a1a6bb7b705
2 parents 7627f4a + a94396d commit 13edfc3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+184
-729
lines changed

clients/GitHub/etc/openapi-client-generator.state

Lines changed: 45 additions & 45 deletions
Large diffs are not rendered by default.

clients/GitHub/src/Client.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

clients/GitHub/src/ClientInterface.php

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\CopilotSeatDetails;
6+
7+
use ApiClients\Client\GitHub\Schema;
8+
use Attribute;
9+
use EventSauce\ObjectHydrator\ObjectMapper;
10+
use EventSauce\ObjectHydrator\PropertyCaster;
11+
use Throwable;
12+
13+
use function array_keys;
14+
use function array_unique;
15+
use function implode;
16+
use function is_array;
17+
use function sort;
18+
19+
#[Attribute(Attribute::TARGET_PARAMETER)]
20+
final class Assignee implements PropertyCaster
21+
{
22+
public function cast(mixed $value, ObjectMapper $hydrator): mixed
23+
{
24+
if (is_array($value)) {
25+
$signatureChunks = array_unique(array_keys($value));
26+
sort($signatureChunks);
27+
$signature = implode('|', $signatureChunks);
28+
if ($signature === 'name|email|login|id|node_id|avatar_url|gravatar_id|url|html_url|followers_url|following_url|gists_url|starred_url|subscriptions_url|organizations_url|repos_url|events_url|received_events_url|type|site_admin|starred_at') {
29+
try {
30+
return $hydrator->hydrateObject(Schema\SimpleUser::class, $value);
31+
} catch (Throwable) {
32+
}
33+
}
34+
35+
if ($signature === 'id|node_id|name|slug|description|privacy|notification_setting|permission|permissions|url|html_url|members_url|repositories_url|parent') {
36+
try {
37+
return $hydrator->hydrateObject(Schema\Team::class, $value);
38+
} catch (Throwable) {
39+
}
40+
}
41+
42+
if ($signature === 'login|url|id|node_id|repos_url|events_url|hooks_url|issues_url|members_url|public_members_url|avatar_url|description|blog|html_url|name|company|location|email|has_organization_projects|has_repository_projects|is_verified|public_repos|public_gists|followers|following|type|created_at|updated_at|plan') {
43+
try {
44+
return $hydrator->hydrateObject(Schema\Organization::class, $value);
45+
} catch (Throwable) {
46+
}
47+
}
48+
}
49+
50+
return $value;
51+
}
52+
}

clients/GitHub/src/Internal/Hydrator/Operation/Orgs/Org/Members/Username/Copilot.php

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
namespace ApiClients\Client\GitHub\Internal\Hydrator\Operation\Orgs\Org\Members\Username;
66

7+
use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\CopilotSeatDetails\Assignee;
78
use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\CopilotSeatDetails\AssigningTeam;
89
use ApiClients\Client\GitHub\Schema\BasicError;
910
use ApiClients\Client\GitHub\Schema\CopilotSeatDetails;
10-
use ApiClients\Client\GitHub\Schema\CopilotSeatDetails\Assignee;
1111
use ApiClients\Client\GitHub\Schema\Team;
1212
use ApiClients\Client\GitHub\Schema\Team\Permissions;
1313
use ApiClients\Client\GitHub\Schema\TeamSimple;
@@ -48,7 +48,6 @@ public function hydrateObject(string $className, array $payload): object
4848
return match ($className) {
4949
'ApiClients\Client\GitHub\Schema\CopilotSeatDetails' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️CopilotSeatDetails($payload),
5050
'ApiClients\Client\GitHub\Schema\BasicError' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($payload),
51-
'ApiClients\Client\GitHub\Schema\CopilotSeatDetails\Assignee' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️CopilotSeatDetails⚡️Assignee($payload),
5251
'ApiClients\Client\GitHub\Schema\Team' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Team($payload),
5352
'ApiClients\Client\GitHub\Schema\Team\Permissions' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Team⚡️Permissions($payload),
5453
'ApiClients\Client\GitHub\Schema\TeamSimple' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️TeamSimple($payload),
@@ -68,13 +67,17 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Copi
6867
goto after_assignee;
6968
}
7069

71-
if (is_array($value)) {
72-
try {
73-
$this->hydrationStack[] = 'assignee';
74-
$value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️CopilotSeatDetails⚡️Assignee($value);
75-
} finally {
76-
array_pop($this->hydrationStack);
77-
}
70+
static $assigneeCaster1;
71+
72+
if ($assigneeCaster1 === null) {
73+
$assigneeCaster1 = new Assignee(...[]);
74+
}
75+
76+
$value = $assigneeCaster1->cast($value, $this);
77+
78+
if ($value === null) {
79+
$missingFields[] = 'assignee';
80+
goto after_assignee;
7881
}
7982

8083
$properties['assignee'] = $value;
@@ -246,26 +249,6 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Basi
246249
}
247250
}
248251

249-
private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️CopilotSeatDetails⚡️Assignee(array $payload): Assignee
250-
{
251-
$properties = [];
252-
$missingFields = [];
253-
try {
254-
} catch (Throwable $exception) {
255-
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\CopilotSeatDetails\Assignee', $exception, stack: $this->hydrationStack);
256-
}
257-
258-
if (count($missingFields) > 0) {
259-
throw UnableToHydrateObject::dueToMissingFields(Assignee::class, $missingFields, stack: $this->hydrationStack);
260-
}
261-
262-
try {
263-
return new Assignee(...$properties);
264-
} catch (Throwable $exception) {
265-
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\CopilotSeatDetails\Assignee', $exception, stack: $this->hydrationStack);
266-
}
267-
}
268-
269252
private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Team(array $payload): Team
270253
{
271254
$properties = [];
@@ -793,8 +776,12 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema
793776
assert($object instanceof CopilotSeatDetails);
794777
$result = [];
795778

796-
$assignee = $object->assignee;
797-
$assignee = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️CopilotSeatDetails⚡️Assignee($assignee);
779+
$assignee = $object->assignee;
780+
$assignee = match ($assignee::class) {
781+
'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($assignee),
782+
'ApiClients\Client\GitHub\Schema\Team' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Team($assignee),
783+
'ApiClients\Client\GitHub\Schema\Organization' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Organization($assignee),
784+
};
798785
after_assignee: $result['assignee'] = $assignee;
799786

800787
$assigningTeam = $object->assigningTeam;

clients/GitHub/src/Internal/Hydrators.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ public function hydrateObject(string $className, array $payload): object
674674
'\\ApiClients\\Client\\GitHub\\Schema\\Operations\\Codespaces\\GetCodespacesForUserInOrg\\Response\\ApplicationJson\\Ok\\Application\\Json' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Members🌀Username🌀Codespaces()->hydrateObject($className, $payload),
675675
'\\ApiClients\\Client\\GitHub\\Schema\\Operations\\Codespaces\\DeleteFromOrganization\\Response\\ApplicationJson\\Accepted\\Application\\Json' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Members🌀Username🌀Codespaces🌀CodespaceName()->hydrateObject($className, $payload),
676676
'\\ApiClients\\Client\\GitHub\\Schema\\Codespace', '\\ApiClients\\Client\\GitHub\\Schema\\CodespaceMachine', '\\ApiClients\\Client\\GitHub\\Schema\\Codespace\\GitStatus', '\\ApiClients\\Client\\GitHub\\Schema\\Codespace\\RuntimeConstraints' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Members🌀Username🌀Codespaces🌀CodespaceName🌀Stop()->hydrateObject($className, $payload),
677-
'\\ApiClients\\Client\\GitHub\\Schema\\CopilotSeatDetails', '\\ApiClients\\Client\\GitHub\\Schema\\CopilotSeatDetails\\Assignee' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Members🌀Username🌀Copilot()->hydrateObject($className, $payload),
677+
'\\ApiClients\\Client\\GitHub\\Schema\\CopilotSeatDetails' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Members🌀Username🌀Copilot()->hydrateObject($className, $payload),
678678
'\\ApiClients\\Client\\GitHub\\Schema\\OrgMembership', '\\ApiClients\\Client\\GitHub\\Schema\\OrganizationSimple', '\\ApiClients\\Client\\GitHub\\Schema\\OrgMembership\\Permissions' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Memberships🌀Username()->hydrateObject($className, $payload),
679679
'\\ApiClients\\Client\\GitHub\\Schema\\Migration' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Migrations()->hydrateObject($className, $payload),
680680
'\\ApiClients\\Client\\GitHub\\Schema\\Operations\\Orgs\\ConvertMemberToOutsideCollaborator\\Response\\ApplicationJson\\Accepted\\Application\\Json', '\\ApiClients\\Client\\GitHub\\Schema\\Operations\\Orgs\\RemoveOutsideCollaborator\\Response\\ApplicationJson\\UnprocessableEntity' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀OutsideCollaborators🌀Username()->hydrateObject($className, $payload),
@@ -937,7 +937,7 @@ public function serializeObjectOfType(object $object, string $className): mixed
937937
'\\ApiClients\\Client\\GitHub\\Schema\\Operations\\Codespaces\\GetCodespacesForUserInOrg\\Response\\ApplicationJson\\Ok\\Application\\Json' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Members🌀Username🌀Codespaces()->serializeObject($object),
938938
'\\ApiClients\\Client\\GitHub\\Schema\\Operations\\Codespaces\\DeleteFromOrganization\\Response\\ApplicationJson\\Accepted\\Application\\Json' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Members🌀Username🌀Codespaces🌀CodespaceName()->serializeObject($object),
939939
'\\ApiClients\\Client\\GitHub\\Schema\\Codespace', '\\ApiClients\\Client\\GitHub\\Schema\\CodespaceMachine', '\\ApiClients\\Client\\GitHub\\Schema\\Codespace\\GitStatus', '\\ApiClients\\Client\\GitHub\\Schema\\Codespace\\RuntimeConstraints' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Members🌀Username🌀Codespaces🌀CodespaceName🌀Stop()->serializeObject($object),
940-
'\\ApiClients\\Client\\GitHub\\Schema\\CopilotSeatDetails', '\\ApiClients\\Client\\GitHub\\Schema\\CopilotSeatDetails\\Assignee' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Members🌀Username🌀Copilot()->serializeObject($object),
940+
'\\ApiClients\\Client\\GitHub\\Schema\\CopilotSeatDetails' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Members🌀Username🌀Copilot()->serializeObject($object),
941941
'\\ApiClients\\Client\\GitHub\\Schema\\OrgMembership', '\\ApiClients\\Client\\GitHub\\Schema\\OrganizationSimple', '\\ApiClients\\Client\\GitHub\\Schema\\OrgMembership\\Permissions' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Memberships🌀Username()->serializeObject($object),
942942
'\\ApiClients\\Client\\GitHub\\Schema\\Migration' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀Migrations()->serializeObject($object),
943943
'\\ApiClients\\Client\\GitHub\\Schema\\Operations\\Orgs\\ConvertMemberToOutsideCollaborator\\Response\\ApplicationJson\\Accepted\\Application\\Json', '\\ApiClients\\Client\\GitHub\\Schema\\Operations\\Orgs\\RemoveOutsideCollaborator\\Response\\ApplicationJson\\UnprocessableEntity' => $this->getObjectMapperOperation🌀Orgs🌀Org🌀OutsideCollaborators🌀Username()->serializeObject($object),

clients/GitHub/src/Internal/Operator/Actions/ForceCancelWorkflowRun.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace ApiClients\Client\GitHub\Internal\Operator\Actions;
66

77
use ApiClients\Client\GitHub\Internal;
8-
use ApiClients\Client\GitHub\Schema;
98
use ApiClients\Client\GitHub\Schema\EmptyObject;
109
use ApiClients\Contracts\HTTP\Headers\AuthenticationInterface;
1110
use League\OpenAPIValidation\Schema\SchemaValidator;
@@ -25,7 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2524
{
2625
}
2726

28-
/** @return Schema\EmptyObject */
27+
/** @return */
2928
public function call(string $owner, string $repo, int $runId): EmptyObject|array
3029
{
3130
$operation = new \ApiClients\Client\GitHub\Internal\Operation\Actions\ForceCancelWorkflowRun($this->responseSchemaValidator, $this->hydrator, $owner, $repo, $runId);

clients/GitHub/src/Internal/Operator/Orgs/GetWebhook.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace ApiClients\Client\GitHub\Internal\Operator\Orgs;
66

77
use ApiClients\Client\GitHub\Internal;
8-
use ApiClients\Client\GitHub\Schema;
98
use ApiClients\Client\GitHub\Schema\OrgHook;
109
use ApiClients\Contracts\HTTP\Headers\AuthenticationInterface;
1110
use League\OpenAPIValidation\Schema\SchemaValidator;
@@ -25,7 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2524
{
2625
}
2726

28-
/** @return Schema\OrgHook */
27+
/** @return */
2928
public function call(string $org, int $hookId): OrgHook|array
3029
{
3130
$operation = new \ApiClients\Client\GitHub\Internal\Operation\Orgs\GetWebhook($this->responseSchemaValidator, $this->hydrator, $org, $hookId);

clients/GitHub/src/Internal/Operator/Orgs/GetWebhookConfigForOrg.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace ApiClients\Client\GitHub\Internal\Operator\Orgs;
66

77
use ApiClients\Client\GitHub\Internal;
8-
use ApiClients\Client\GitHub\Schema;
98
use ApiClients\Client\GitHub\Schema\WebhookConfig;
109
use ApiClients\Contracts\HTTP\Headers\AuthenticationInterface;
1110
use League\OpenAPIValidation\Schema\SchemaValidator;
@@ -25,7 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2524
{
2625
}
2726

28-
/** @return Schema\WebhookConfig */
27+
/** @return */
2928
public function call(string $org, int $hookId): WebhookConfig|array
3029
{
3130
$operation = new \ApiClients\Client\GitHub\Internal\Operation\Orgs\GetWebhookConfigForOrg($this->responseSchemaValidator, $this->hydrator, $org, $hookId);

clients/GitHub/src/Internal/Operator/Orgs/GetWebhookDelivery.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace ApiClients\Client\GitHub\Internal\Operator\Orgs;
66

77
use ApiClients\Client\GitHub\Internal;
8-
use ApiClients\Client\GitHub\Schema;
98
use ApiClients\Client\GitHub\Schema\HookDelivery;
109
use ApiClients\Contracts\HTTP\Headers\AuthenticationInterface;
1110
use League\OpenAPIValidation\Schema\SchemaValidator;
@@ -25,7 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2524
{
2625
}
2726

28-
/** @return Schema\HookDelivery */
27+
/** @return */
2928
public function call(string $org, int $hookId, int $deliveryId): HookDelivery|array
3029
{
3130
$operation = new \ApiClients\Client\GitHub\Internal\Operation\Orgs\GetWebhookDelivery($this->responseSchemaValidator, $this->hydrator, $org, $hookId, $deliveryId);

0 commit comments

Comments
 (0)