From ff240f5befe9598ad5365285d9a3cba8b7c7171c Mon Sep 17 00:00:00 2001 From: WyriHaximus <147145+WyriHaximus@users.noreply.github.com> Date: Wed, 10 Jul 2024 16:53:33 +0000 Subject: [PATCH] [GitHub] Update to 1.1.4-bd1a2cde4ef1f12a463c3206d4665fb8 from 1.1.4-ed9f9c8a528083c4f510bc9ec29e7cbc Detected Schema changes: starting work. Building original model for commit 1f1e00 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` SPEC: extracted 2 commits from history └─┬Components └─┬commit ├─┬committer │ ├──[➖] type (78129:11)❌ │ ├──[➕] anyOf (78123:13) │ ├──[➕] anyOf (63803:7) │ ├──[➖] oneOf (70391:7)❌ │ └──[➖] oneOf (63803:7)❌ └─┬author ├──[➖] type (78122:11)❌ ├──[➕] anyOf (78119:13) ├──[➕] anyOf (63803:7) ├──[➖] oneOf (70391:7)❌ └──[➖] oneOf (63803:7)❌ ``` | Document Element | Total Changes | Breaking Changes | |------------------|---------------|------------------| | components | 10 | 6 | Date: 07/10/24 | Commit: New: etc/specs/GitHub/previous.spec.yaml, Original: etc/specs/GitHub/current.spec.yaml - ❌ **BREAKING Changes**: _6_ out of _10_ - **Removals**: _6_ - **Additions**: _4_ - **Breaking Removals**: _6_ ERROR: breaking changes discovered --- .../GitHub/etc/openapi-client-generator.state | 38 +- .../CastUnionToType/Schema/Commit/Author.php | 45 ++ .../Schema/Commit/Committer.php | 45 ++ .../Repos/Owner/Repo/Branches/Branch.php | 406 ++---------------- .../Owner/Repo/Branches/Branch/Rename.php | 406 ++---------------- .../Repos/Owner/Repo/Commits/Ref.php | 406 ++---------------- .../Repos/Owner/Repo/Compare/Basehead.php | 406 ++---------------- .../Operation/Repos/Owner/Repo/Merges.php | 406 ++---------------- .../Operator/Orgs/AddSecurityManagerTeam.php | 1 + .../GitHub/src/Internal/Router/Put/Orgs.php | 1 + .../GitHub/src/Internal/Router/Put/Six.php | 1 - clients/GitHub/src/Operation/Orgs.php | 1 + .../src/PHPStan/ClientCallReturnTypes.php | 2 +- .../src/Schema/BranchWithProtection.php | 80 ++-- clients/GitHub/src/Schema/Commit.php | 86 ++-- .../GitHub/src/Schema/CommitComparison.php | 288 ++++--------- .../tests/Types/ClientCallReturnTypes.php | 2 +- etc/specs/GitHub/current.spec.yaml | 14 +- 18 files changed, 435 insertions(+), 2199 deletions(-) create mode 100644 clients/GitHub/src/Internal/Attribute/CastUnionToType/Schema/Commit/Author.php create mode 100644 clients/GitHub/src/Internal/Attribute/CastUnionToType/Schema/Commit/Committer.php diff --git a/clients/GitHub/etc/openapi-client-generator.state b/clients/GitHub/etc/openapi-client-generator.state index 303a7b8f7d4..5e4283f73e1 100644 --- a/clients/GitHub/etc/openapi-client-generator.state +++ b/clients/GitHub/etc/openapi-client-generator.state @@ -1,5 +1,5 @@ { - "specHash": "ed9f9c8a528083c4f510bc9ec29e7cbc", + "specHash": "bd1a2cde4ef1f12a463c3206d4665fb8", "generatedFiles": { "files": [ { @@ -808,11 +808,11 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Schema\/Commit.php", - "hash": "fecf1872a093ef9b8e030d1b85ec04d6" + "hash": "5d4e74927c311c39a5bf5a2128703049" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Schema\/BranchWithProtection.php", - "hash": "a2d1dc45500db9335f41f494d54cde28" + "hash": "abe7bf076fd01ba2a37c645792410f3b" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Schema\/StatusCheckPolicy.php", @@ -976,7 +976,7 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Schema\/CommitComparison.php", - "hash": "102c311bc331cb4727727a168dff9480" + "hash": "2f47b90f82deea1f53f7eb05b19d0832" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Schema\/ContentTree.php", @@ -5576,7 +5576,7 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Operation\/Orgs.php", - "hash": "b70830c3e9116294d4024aa1c4b96d82" + "hash": "9cc8a952a09ba39d91e86ea451a347e8" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Operation\/Actions.php", @@ -15256,7 +15256,7 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Operator\/Orgs\/AddSecurityManagerTeam.php", - "hash": "d2fce870b2cb247448df55fad25e7db6" + "hash": "2e655db0da01ce7954a01700e3299829" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Operation\/Orgs\/RemoveSecurityManagerTeam.php", @@ -24888,7 +24888,7 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Put\/Orgs.php", - "hash": "036a72c9ebe842c9829dfcc14984247a" + "hash": "d9fa1cd41ee4ef5dc9e80b71f39c5771" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Put\/Codespaces.php", @@ -25144,7 +25144,7 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Put\/Six.php", - "hash": "0e732f175758864698227b1f673bf2b3" + "hash": "2d193ba8e2a36a3ea0fe0a7e952dd209" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Router\/Put\/Eight.php", @@ -26028,7 +26028,7 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Repos\/Owner\/Repo\/Branches\/Branch.php", - "hash": "ea6f9da0e8c8911a0613ddc66b7cf2ed" + "hash": "025dcd472975b0fb7c72bb928995c634" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Repos\/Owner\/Repo\/Branches\/Branch\/Protection.php", @@ -26072,7 +26072,7 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Repos\/Owner\/Repo\/Branches\/Branch\/Rename.php", - "hash": "a1c0237c73b0ddd223f409c459bebcee" + "hash": "5f16afe381efaca4e1ea38bfa312b7f1" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Repos\/Owner\/Repo\/CheckRuns.php", @@ -26212,7 +26212,7 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Repos\/Owner\/Repo\/Commits\/Ref.php", - "hash": "5438585603d89e956a174d7f30da8387" + "hash": "70fcc6d425b1790fa9d8652892f669d8" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Repos\/Owner\/Repo\/Commits\/Ref\/CheckRuns.php", @@ -26236,7 +26236,7 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Repos\/Owner\/Repo\/Compare\/Basehead.php", - "hash": "bfc9ee03d219636623bbde3a938b2751" + "hash": "a1d5fd3ac5695b04a52bc309e55d04a3" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Repos\/Owner\/Repo\/Contents\/Path.php", @@ -26532,7 +26532,7 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Repos\/Owner\/Repo\/Merges.php", - "hash": "85d84ac03b6d73d3eb8024e91354dc87" + "hash": "eb5c1ca126517bbbbafb6d18583d3868" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Hydrator\/Operation\/Repos\/Owner\/Repo\/Milestones.php", @@ -27788,11 +27788,11 @@ }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/PHPStan\/ClientCallReturnTypes.php", - "hash": "e7abe40b6c23a63db1d22af67a244d0a" + "hash": "34097be811968901ed3316c689e3d3eb" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/tests\/\/Types\/ClientCallReturnTypes.php", - "hash": "0d934126b3c4a55fdb6b817bd106c15e" + "hash": "b24dfb45ef8936c0dcfc11f99fb51c47" }, { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/..\/etc\/phpstan-extension.neon", @@ -30285,6 +30285,14 @@ { "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Schema\/AliasAbstract\/TietA56E04B2\/Tiet87E35262\/Tiet960294EF\/Tiet9CED5A0E.php", "hash": "2cc0aacc6a4cef12676e8a260c2b0e83" + }, + { + "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Attribute\/CastUnionToType\/Schema\/Commit\/Author.php", + "hash": "ac1b7172489166e89480b03255d9beac" + }, + { + "name": ".\/clients\/GitHub\/etc\/..\/\/src\/\/Internal\/Attribute\/CastUnionToType\/Schema\/Commit\/Committer.php", + "hash": "e7db03df5ee771f105cc3dc7a3aa517e" } ] }, diff --git a/clients/GitHub/src/Internal/Attribute/CastUnionToType/Schema/Commit/Author.php b/clients/GitHub/src/Internal/Attribute/CastUnionToType/Schema/Commit/Author.php new file mode 100644 index 00000000000..bb6e2e946d6 --- /dev/null +++ b/clients/GitHub/src/Internal/Attribute/CastUnionToType/Schema/Commit/Author.php @@ -0,0 +1,45 @@ +hydrateObject(Schema\SimpleUser::class, $value); + } catch (Throwable) { + } + } + + if ($signature === '') { + try { + return $hydrator->hydrateObject(Schema\EmptyObject::class, $value); + } catch (Throwable) { + } + } + } + + return $value; + } +} diff --git a/clients/GitHub/src/Internal/Attribute/CastUnionToType/Schema/Commit/Committer.php b/clients/GitHub/src/Internal/Attribute/CastUnionToType/Schema/Commit/Committer.php new file mode 100644 index 00000000000..51739daf363 --- /dev/null +++ b/clients/GitHub/src/Internal/Attribute/CastUnionToType/Schema/Commit/Committer.php @@ -0,0 +1,45 @@ +hydrateObject(Schema\SimpleUser::class, $value); + } catch (Throwable) { + } + } + + if ($signature === '') { + try { + return $hydrator->hydrateObject(Schema\EmptyObject::class, $value); + } catch (Throwable) { + } + } + } + + return $value; + } +} diff --git a/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Branches/Branch.php b/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Branches/Branch.php index 7b95e897998..3f412aa14c8 100644 --- a/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Branches/Branch.php +++ b/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Branches/Branch.php @@ -4,6 +4,8 @@ namespace ApiClients\Client\GitHub\Internal\Hydrator\Operation\Repos\Owner\Repo\Branches; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Author; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Committer; use ApiClients\Client\GitHub\Schema\BasicError; use ApiClients\Client\GitHub\Schema\BranchProtection; use ApiClients\Client\GitHub\Schema\BranchProtection\AllowDeletions; @@ -26,7 +28,6 @@ use ApiClients\Client\GitHub\Schema\ProtectedBranchPullRequestReview\BypassPullRequestAllowances; use ApiClients\Client\GitHub\Schema\ProtectedBranchPullRequestReview\DismissalRestrictions; use ApiClients\Client\GitHub\Schema\ProtectedBranchRequiredStatusCheck; -use ApiClients\Client\GitHub\Schema\SimpleUser; use ApiClients\Client\GitHub\Schema\Verification; use EventSauce\ObjectHydrator\IterableList; use EventSauce\ObjectHydrator\ObjectMapper; @@ -69,7 +70,6 @@ public function hydrateObject(string $className, array $payload): object 'ApiClients\Client\GitHub\Schema\GitUser' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️GitUser($payload), 'ApiClients\Client\GitHub\Schema\Commit\Commit\Tree' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Commit⚡️Tree($payload), 'ApiClients\Client\GitHub\Schema\Verification' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Verification($payload), - 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($payload), 'ApiClients\Client\GitHub\Schema\Commit\Stats' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats($payload), 'ApiClients\Client\GitHub\Schema\BranchWithProtection\Links' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BranchWithProtection⚡️Links($payload), 'ApiClients\Client\GitHub\Schema\BranchProtection' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BranchProtection($payload), @@ -309,17 +309,21 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Comm $value = $payload['author'] ?? null; if ($value === null) { - $properties['author'] = null; + $missingFields[] = 'author'; goto after_author; } - if (is_array($value)) { - try { - $this->hydrationStack[] = 'author'; - $value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($value); - } finally { - array_pop($this->hydrationStack); - } + static $authorCaster1; + + if ($authorCaster1 === null) { + $authorCaster1 = new Author(...[]); + } + + $value = $authorCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'author'; + goto after_author; } $properties['author'] = $value; @@ -329,17 +333,21 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Comm $value = $payload['committer'] ?? null; if ($value === null) { - $properties['committer'] = null; + $missingFields[] = 'committer'; goto after_committer; } - if (is_array($value)) { - try { - $this->hydrationStack[] = 'committer'; - $value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($value); - } finally { - array_pop($this->hydrationStack); - } + static $committerCaster1; + + if ($committerCaster1 === null) { + $committerCaster1 = new Committer(...[]); + } + + $value = $committerCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'committer'; + goto after_committer; } $properties['committer'] = $value; @@ -690,256 +698,6 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Veri } } - private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser(array $payload): SimpleUser - { - $properties = []; - $missingFields = []; - try { - $value = $payload['name'] ?? null; - - if ($value === null) { - $properties['name'] = null; - goto after_name; - } - - $properties['name'] = $value; - - after_name: - - $value = $payload['email'] ?? null; - - if ($value === null) { - $properties['email'] = null; - goto after_email; - } - - $properties['email'] = $value; - - after_email: - - $value = $payload['login'] ?? null; - - if ($value === null) { - $missingFields[] = 'login'; - goto after_login; - } - - $properties['login'] = $value; - - after_login: - - $value = $payload['id'] ?? null; - - if ($value === null) { - $missingFields[] = 'id'; - goto after_id; - } - - $properties['id'] = $value; - - after_id: - - $value = $payload['node_id'] ?? null; - - if ($value === null) { - $missingFields[] = 'node_id'; - goto after_nodeId; - } - - $properties['nodeId'] = $value; - - after_nodeId: - - $value = $payload['avatar_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'avatar_url'; - goto after_avatarUrl; - } - - $properties['avatarUrl'] = $value; - - after_avatarUrl: - - $value = $payload['gravatar_id'] ?? null; - - if ($value === null) { - $properties['gravatarId'] = null; - goto after_gravatarId; - } - - $properties['gravatarId'] = $value; - - after_gravatarId: - - $value = $payload['url'] ?? null; - - if ($value === null) { - $missingFields[] = 'url'; - goto after_url; - } - - $properties['url'] = $value; - - after_url: - - $value = $payload['html_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'html_url'; - goto after_htmlUrl; - } - - $properties['htmlUrl'] = $value; - - after_htmlUrl: - - $value = $payload['followers_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'followers_url'; - goto after_followersUrl; - } - - $properties['followersUrl'] = $value; - - after_followersUrl: - - $value = $payload['following_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'following_url'; - goto after_followingUrl; - } - - $properties['followingUrl'] = $value; - - after_followingUrl: - - $value = $payload['gists_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'gists_url'; - goto after_gistsUrl; - } - - $properties['gistsUrl'] = $value; - - after_gistsUrl: - - $value = $payload['starred_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'starred_url'; - goto after_starredUrl; - } - - $properties['starredUrl'] = $value; - - after_starredUrl: - - $value = $payload['subscriptions_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'subscriptions_url'; - goto after_subscriptionsUrl; - } - - $properties['subscriptionsUrl'] = $value; - - after_subscriptionsUrl: - - $value = $payload['organizations_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'organizations_url'; - goto after_organizationsUrl; - } - - $properties['organizationsUrl'] = $value; - - after_organizationsUrl: - - $value = $payload['repos_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'repos_url'; - goto after_reposUrl; - } - - $properties['reposUrl'] = $value; - - after_reposUrl: - - $value = $payload['events_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'events_url'; - goto after_eventsUrl; - } - - $properties['eventsUrl'] = $value; - - after_eventsUrl: - - $value = $payload['received_events_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'received_events_url'; - goto after_receivedEventsUrl; - } - - $properties['receivedEventsUrl'] = $value; - - after_receivedEventsUrl: - - $value = $payload['type'] ?? null; - - if ($value === null) { - $missingFields[] = 'type'; - goto after_type; - } - - $properties['type'] = $value; - - after_type: - - $value = $payload['site_admin'] ?? null; - - if ($value === null) { - $missingFields[] = 'site_admin'; - goto after_siteAdmin; - } - - $properties['siteAdmin'] = $value; - - after_siteAdmin: - - $value = $payload['starred_at'] ?? null; - - if ($value === null) { - $properties['starredAt'] = null; - goto after_starredAt; - } - - $properties['starredAt'] = $value; - - after_starredAt: - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\SimpleUser', $exception, stack: $this->hydrationStack); - } - - if (count($missingFields) > 0) { - throw UnableToHydrateObject::dueToMissingFields(SimpleUser::class, $missingFields, stack: $this->hydrationStack); - } - - try { - return new SimpleUser(...$properties); - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\SimpleUser', $exception, stack: $this->hydrationStack); - } - } - private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats(array $payload): Stats { $properties = []; @@ -2160,7 +1918,6 @@ public function serializeObjectOfType(object $object, string $className): mixed 'ApiClients\Client\GitHub\Schema\GitUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️GitUser($object), 'ApiClients\Client\GitHub\Schema\Commit\Commit\Tree' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Commit⚡️Tree($object), 'ApiClients\Client\GitHub\Schema\Verification' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Verification($object), - 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($object), 'ApiClients\Client\GitHub\Schema\Commit\Stats' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats($object), 'ApiClients\Client\GitHub\Schema\BranchWithProtection\Links' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BranchWithProtection⚡️Links($object), 'ApiClients\Client\GitHub\Schema\BranchProtection' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BranchProtection($object), @@ -2311,21 +2068,17 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema after_commit: $result['commit'] = $commit; $author = $object->author; - - if ($author === null) { - goto after_author; - } - - $author = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($author); + $author = match ($author::class) { + 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($author), + 'ApiClients\Client\GitHub\Schema\EmptyObject' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️EmptyObject($author), + }; after_author: $result['author'] = $author; $committer = $object->committer; - - if ($committer === null) { - goto after_committer; - } - - $committer = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($committer); + $committer = match ($committer::class) { + 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($committer), + 'ApiClients\Client\GitHub\Schema\EmptyObject' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️EmptyObject($committer), + }; after_committer: $result['committer'] = $committer; $parents = $object->parents; @@ -2489,97 +2242,6 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema return $result; } - private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser(mixed $object): mixed - { - assert($object instanceof SimpleUser); - $result = []; - - $name = $object->name; - - if ($name === null) { - goto after_name; - } - - after_name: $result['name'] = $name; - - $email = $object->email; - - if ($email === null) { - goto after_email; - } - - after_email: $result['email'] = $email; - - $login = $object->login; - after_login: $result['login'] = $login; - - $id = $object->id; - after_id: $result['id'] = $id; - - $nodeId = $object->nodeId; - after_nodeId: $result['node_id'] = $nodeId; - - $avatarUrl = $object->avatarUrl; - after_avatarUrl: $result['avatar_url'] = $avatarUrl; - - $gravatarId = $object->gravatarId; - - if ($gravatarId === null) { - goto after_gravatarId; - } - - after_gravatarId: $result['gravatar_id'] = $gravatarId; - - $url = $object->url; - after_url: $result['url'] = $url; - - $htmlUrl = $object->htmlUrl; - after_htmlUrl: $result['html_url'] = $htmlUrl; - - $followersUrl = $object->followersUrl; - after_followersUrl: $result['followers_url'] = $followersUrl; - - $followingUrl = $object->followingUrl; - after_followingUrl: $result['following_url'] = $followingUrl; - - $gistsUrl = $object->gistsUrl; - after_gistsUrl: $result['gists_url'] = $gistsUrl; - - $starredUrl = $object->starredUrl; - after_starredUrl: $result['starred_url'] = $starredUrl; - - $subscriptionsUrl = $object->subscriptionsUrl; - after_subscriptionsUrl: $result['subscriptions_url'] = $subscriptionsUrl; - - $organizationsUrl = $object->organizationsUrl; - after_organizationsUrl: $result['organizations_url'] = $organizationsUrl; - - $reposUrl = $object->reposUrl; - after_reposUrl: $result['repos_url'] = $reposUrl; - - $eventsUrl = $object->eventsUrl; - after_eventsUrl: $result['events_url'] = $eventsUrl; - - $receivedEventsUrl = $object->receivedEventsUrl; - after_receivedEventsUrl: $result['received_events_url'] = $receivedEventsUrl; - - $type = $object->type; - after_type: $result['type'] = $type; - - $siteAdmin = $object->siteAdmin; - after_siteAdmin: $result['site_admin'] = $siteAdmin; - - $starredAt = $object->starredAt; - - if ($starredAt === null) { - goto after_starredAt; - } - - after_starredAt: $result['starred_at'] = $starredAt; - - return $result; - } - private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats(mixed $object): mixed { assert($object instanceof Stats); diff --git a/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Branches/Branch/Rename.php b/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Branches/Branch/Rename.php index 96e596658e4..8ce12a50eee 100644 --- a/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Branches/Branch/Rename.php +++ b/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Branches/Branch/Rename.php @@ -4,6 +4,8 @@ namespace ApiClients\Client\GitHub\Internal\Hydrator\Operation\Repos\Owner\Repo\Branches\Branch; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Author; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Committer; use ApiClients\Client\GitHub\Schema\BasicError; use ApiClients\Client\GitHub\Schema\BranchProtection; use ApiClients\Client\GitHub\Schema\BranchProtection\AllowDeletions; @@ -26,7 +28,6 @@ use ApiClients\Client\GitHub\Schema\ProtectedBranchPullRequestReview\BypassPullRequestAllowances; use ApiClients\Client\GitHub\Schema\ProtectedBranchPullRequestReview\DismissalRestrictions; use ApiClients\Client\GitHub\Schema\ProtectedBranchRequiredStatusCheck; -use ApiClients\Client\GitHub\Schema\SimpleUser; use ApiClients\Client\GitHub\Schema\ValidationError; use ApiClients\Client\GitHub\Schema\Verification; use EventSauce\ObjectHydrator\IterableList; @@ -70,7 +71,6 @@ public function hydrateObject(string $className, array $payload): object 'ApiClients\Client\GitHub\Schema\GitUser' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️GitUser($payload), 'ApiClients\Client\GitHub\Schema\Commit\Commit\Tree' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Commit⚡️Tree($payload), 'ApiClients\Client\GitHub\Schema\Verification' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Verification($payload), - 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($payload), 'ApiClients\Client\GitHub\Schema\Commit\Stats' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats($payload), 'ApiClients\Client\GitHub\Schema\BranchWithProtection\Links' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BranchWithProtection⚡️Links($payload), 'ApiClients\Client\GitHub\Schema\BranchProtection' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BranchProtection($payload), @@ -311,17 +311,21 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Comm $value = $payload['author'] ?? null; if ($value === null) { - $properties['author'] = null; + $missingFields[] = 'author'; goto after_author; } - if (is_array($value)) { - try { - $this->hydrationStack[] = 'author'; - $value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($value); - } finally { - array_pop($this->hydrationStack); - } + static $authorCaster1; + + if ($authorCaster1 === null) { + $authorCaster1 = new Author(...[]); + } + + $value = $authorCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'author'; + goto after_author; } $properties['author'] = $value; @@ -331,17 +335,21 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Comm $value = $payload['committer'] ?? null; if ($value === null) { - $properties['committer'] = null; + $missingFields[] = 'committer'; goto after_committer; } - if (is_array($value)) { - try { - $this->hydrationStack[] = 'committer'; - $value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($value); - } finally { - array_pop($this->hydrationStack); - } + static $committerCaster1; + + if ($committerCaster1 === null) { + $committerCaster1 = new Committer(...[]); + } + + $value = $committerCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'committer'; + goto after_committer; } $properties['committer'] = $value; @@ -692,256 +700,6 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Veri } } - private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser(array $payload): SimpleUser - { - $properties = []; - $missingFields = []; - try { - $value = $payload['name'] ?? null; - - if ($value === null) { - $properties['name'] = null; - goto after_name; - } - - $properties['name'] = $value; - - after_name: - - $value = $payload['email'] ?? null; - - if ($value === null) { - $properties['email'] = null; - goto after_email; - } - - $properties['email'] = $value; - - after_email: - - $value = $payload['login'] ?? null; - - if ($value === null) { - $missingFields[] = 'login'; - goto after_login; - } - - $properties['login'] = $value; - - after_login: - - $value = $payload['id'] ?? null; - - if ($value === null) { - $missingFields[] = 'id'; - goto after_id; - } - - $properties['id'] = $value; - - after_id: - - $value = $payload['node_id'] ?? null; - - if ($value === null) { - $missingFields[] = 'node_id'; - goto after_nodeId; - } - - $properties['nodeId'] = $value; - - after_nodeId: - - $value = $payload['avatar_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'avatar_url'; - goto after_avatarUrl; - } - - $properties['avatarUrl'] = $value; - - after_avatarUrl: - - $value = $payload['gravatar_id'] ?? null; - - if ($value === null) { - $properties['gravatarId'] = null; - goto after_gravatarId; - } - - $properties['gravatarId'] = $value; - - after_gravatarId: - - $value = $payload['url'] ?? null; - - if ($value === null) { - $missingFields[] = 'url'; - goto after_url; - } - - $properties['url'] = $value; - - after_url: - - $value = $payload['html_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'html_url'; - goto after_htmlUrl; - } - - $properties['htmlUrl'] = $value; - - after_htmlUrl: - - $value = $payload['followers_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'followers_url'; - goto after_followersUrl; - } - - $properties['followersUrl'] = $value; - - after_followersUrl: - - $value = $payload['following_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'following_url'; - goto after_followingUrl; - } - - $properties['followingUrl'] = $value; - - after_followingUrl: - - $value = $payload['gists_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'gists_url'; - goto after_gistsUrl; - } - - $properties['gistsUrl'] = $value; - - after_gistsUrl: - - $value = $payload['starred_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'starred_url'; - goto after_starredUrl; - } - - $properties['starredUrl'] = $value; - - after_starredUrl: - - $value = $payload['subscriptions_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'subscriptions_url'; - goto after_subscriptionsUrl; - } - - $properties['subscriptionsUrl'] = $value; - - after_subscriptionsUrl: - - $value = $payload['organizations_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'organizations_url'; - goto after_organizationsUrl; - } - - $properties['organizationsUrl'] = $value; - - after_organizationsUrl: - - $value = $payload['repos_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'repos_url'; - goto after_reposUrl; - } - - $properties['reposUrl'] = $value; - - after_reposUrl: - - $value = $payload['events_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'events_url'; - goto after_eventsUrl; - } - - $properties['eventsUrl'] = $value; - - after_eventsUrl: - - $value = $payload['received_events_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'received_events_url'; - goto after_receivedEventsUrl; - } - - $properties['receivedEventsUrl'] = $value; - - after_receivedEventsUrl: - - $value = $payload['type'] ?? null; - - if ($value === null) { - $missingFields[] = 'type'; - goto after_type; - } - - $properties['type'] = $value; - - after_type: - - $value = $payload['site_admin'] ?? null; - - if ($value === null) { - $missingFields[] = 'site_admin'; - goto after_siteAdmin; - } - - $properties['siteAdmin'] = $value; - - after_siteAdmin: - - $value = $payload['starred_at'] ?? null; - - if ($value === null) { - $properties['starredAt'] = null; - goto after_starredAt; - } - - $properties['starredAt'] = $value; - - after_starredAt: - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\SimpleUser', $exception, stack: $this->hydrationStack); - } - - if (count($missingFields) > 0) { - throw UnableToHydrateObject::dueToMissingFields(SimpleUser::class, $missingFields, stack: $this->hydrationStack); - } - - try { - return new SimpleUser(...$properties); - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\SimpleUser', $exception, stack: $this->hydrationStack); - } - } - private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats(array $payload): Stats { $properties = []; @@ -2214,7 +1972,6 @@ public function serializeObjectOfType(object $object, string $className): mixed 'ApiClients\Client\GitHub\Schema\GitUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️GitUser($object), 'ApiClients\Client\GitHub\Schema\Commit\Commit\Tree' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Commit⚡️Tree($object), 'ApiClients\Client\GitHub\Schema\Verification' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Verification($object), - 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($object), 'ApiClients\Client\GitHub\Schema\Commit\Stats' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats($object), 'ApiClients\Client\GitHub\Schema\BranchWithProtection\Links' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BranchWithProtection⚡️Links($object), 'ApiClients\Client\GitHub\Schema\BranchProtection' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BranchProtection($object), @@ -2366,21 +2123,17 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema after_commit: $result['commit'] = $commit; $author = $object->author; - - if ($author === null) { - goto after_author; - } - - $author = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($author); + $author = match ($author::class) { + 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($author), + 'ApiClients\Client\GitHub\Schema\EmptyObject' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️EmptyObject($author), + }; after_author: $result['author'] = $author; $committer = $object->committer; - - if ($committer === null) { - goto after_committer; - } - - $committer = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($committer); + $committer = match ($committer::class) { + 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($committer), + 'ApiClients\Client\GitHub\Schema\EmptyObject' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️EmptyObject($committer), + }; after_committer: $result['committer'] = $committer; $parents = $object->parents; @@ -2544,97 +2297,6 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema return $result; } - private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser(mixed $object): mixed - { - assert($object instanceof SimpleUser); - $result = []; - - $name = $object->name; - - if ($name === null) { - goto after_name; - } - - after_name: $result['name'] = $name; - - $email = $object->email; - - if ($email === null) { - goto after_email; - } - - after_email: $result['email'] = $email; - - $login = $object->login; - after_login: $result['login'] = $login; - - $id = $object->id; - after_id: $result['id'] = $id; - - $nodeId = $object->nodeId; - after_nodeId: $result['node_id'] = $nodeId; - - $avatarUrl = $object->avatarUrl; - after_avatarUrl: $result['avatar_url'] = $avatarUrl; - - $gravatarId = $object->gravatarId; - - if ($gravatarId === null) { - goto after_gravatarId; - } - - after_gravatarId: $result['gravatar_id'] = $gravatarId; - - $url = $object->url; - after_url: $result['url'] = $url; - - $htmlUrl = $object->htmlUrl; - after_htmlUrl: $result['html_url'] = $htmlUrl; - - $followersUrl = $object->followersUrl; - after_followersUrl: $result['followers_url'] = $followersUrl; - - $followingUrl = $object->followingUrl; - after_followingUrl: $result['following_url'] = $followingUrl; - - $gistsUrl = $object->gistsUrl; - after_gistsUrl: $result['gists_url'] = $gistsUrl; - - $starredUrl = $object->starredUrl; - after_starredUrl: $result['starred_url'] = $starredUrl; - - $subscriptionsUrl = $object->subscriptionsUrl; - after_subscriptionsUrl: $result['subscriptions_url'] = $subscriptionsUrl; - - $organizationsUrl = $object->organizationsUrl; - after_organizationsUrl: $result['organizations_url'] = $organizationsUrl; - - $reposUrl = $object->reposUrl; - after_reposUrl: $result['repos_url'] = $reposUrl; - - $eventsUrl = $object->eventsUrl; - after_eventsUrl: $result['events_url'] = $eventsUrl; - - $receivedEventsUrl = $object->receivedEventsUrl; - after_receivedEventsUrl: $result['received_events_url'] = $receivedEventsUrl; - - $type = $object->type; - after_type: $result['type'] = $type; - - $siteAdmin = $object->siteAdmin; - after_siteAdmin: $result['site_admin'] = $siteAdmin; - - $starredAt = $object->starredAt; - - if ($starredAt === null) { - goto after_starredAt; - } - - after_starredAt: $result['starred_at'] = $starredAt; - - return $result; - } - private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats(mixed $object): mixed { assert($object instanceof Stats); diff --git a/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Commits/Ref.php b/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Commits/Ref.php index d7c79f0a98e..fde3799bc72 100644 --- a/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Commits/Ref.php +++ b/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Commits/Ref.php @@ -4,13 +4,14 @@ namespace ApiClients\Client\GitHub\Internal\Hydrator\Operation\Repos\Owner\Repo\Commits; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Author; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Committer; use ApiClients\Client\GitHub\Schema\BasicError; use ApiClients\Client\GitHub\Schema\Commit; use ApiClients\Client\GitHub\Schema\Commit\Commit\Tree; use ApiClients\Client\GitHub\Schema\Commit\Stats; use ApiClients\Client\GitHub\Schema\GitUser; use ApiClients\Client\GitHub\Schema\Operations\SecretScanning\ListAlertsForEnterprise\Response\ApplicationJson\ServiceUnavailable; -use ApiClients\Client\GitHub\Schema\SimpleUser; use ApiClients\Client\GitHub\Schema\ValidationError; use ApiClients\Client\GitHub\Schema\Verification; use EventSauce\ObjectHydrator\IterableList; @@ -53,7 +54,6 @@ public function hydrateObject(string $className, array $payload): object 'ApiClients\Client\GitHub\Schema\GitUser' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️GitUser($payload), 'ApiClients\Client\GitHub\Schema\Commit\Commit\Tree' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Commit⚡️Tree($payload), 'ApiClients\Client\GitHub\Schema\Verification' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Verification($payload), - 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($payload), 'ApiClients\Client\GitHub\Schema\Commit\Stats' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats($payload), 'ApiClients\Client\GitHub\Schema\ValidationError' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️ValidationError($payload), 'ApiClients\Client\GitHub\Schema\BasicError' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($payload), @@ -145,17 +145,21 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Comm $value = $payload['author'] ?? null; if ($value === null) { - $properties['author'] = null; + $missingFields[] = 'author'; goto after_author; } - if (is_array($value)) { - try { - $this->hydrationStack[] = 'author'; - $value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($value); - } finally { - array_pop($this->hydrationStack); - } + static $authorCaster1; + + if ($authorCaster1 === null) { + $authorCaster1 = new Author(...[]); + } + + $value = $authorCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'author'; + goto after_author; } $properties['author'] = $value; @@ -165,17 +169,21 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Comm $value = $payload['committer'] ?? null; if ($value === null) { - $properties['committer'] = null; + $missingFields[] = 'committer'; goto after_committer; } - if (is_array($value)) { - try { - $this->hydrationStack[] = 'committer'; - $value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($value); - } finally { - array_pop($this->hydrationStack); - } + static $committerCaster1; + + if ($committerCaster1 === null) { + $committerCaster1 = new Committer(...[]); + } + + $value = $committerCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'committer'; + goto after_committer; } $properties['committer'] = $value; @@ -526,256 +534,6 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Veri } } - private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser(array $payload): SimpleUser - { - $properties = []; - $missingFields = []; - try { - $value = $payload['name'] ?? null; - - if ($value === null) { - $properties['name'] = null; - goto after_name; - } - - $properties['name'] = $value; - - after_name: - - $value = $payload['email'] ?? null; - - if ($value === null) { - $properties['email'] = null; - goto after_email; - } - - $properties['email'] = $value; - - after_email: - - $value = $payload['login'] ?? null; - - if ($value === null) { - $missingFields[] = 'login'; - goto after_login; - } - - $properties['login'] = $value; - - after_login: - - $value = $payload['id'] ?? null; - - if ($value === null) { - $missingFields[] = 'id'; - goto after_id; - } - - $properties['id'] = $value; - - after_id: - - $value = $payload['node_id'] ?? null; - - if ($value === null) { - $missingFields[] = 'node_id'; - goto after_nodeId; - } - - $properties['nodeId'] = $value; - - after_nodeId: - - $value = $payload['avatar_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'avatar_url'; - goto after_avatarUrl; - } - - $properties['avatarUrl'] = $value; - - after_avatarUrl: - - $value = $payload['gravatar_id'] ?? null; - - if ($value === null) { - $properties['gravatarId'] = null; - goto after_gravatarId; - } - - $properties['gravatarId'] = $value; - - after_gravatarId: - - $value = $payload['url'] ?? null; - - if ($value === null) { - $missingFields[] = 'url'; - goto after_url; - } - - $properties['url'] = $value; - - after_url: - - $value = $payload['html_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'html_url'; - goto after_htmlUrl; - } - - $properties['htmlUrl'] = $value; - - after_htmlUrl: - - $value = $payload['followers_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'followers_url'; - goto after_followersUrl; - } - - $properties['followersUrl'] = $value; - - after_followersUrl: - - $value = $payload['following_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'following_url'; - goto after_followingUrl; - } - - $properties['followingUrl'] = $value; - - after_followingUrl: - - $value = $payload['gists_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'gists_url'; - goto after_gistsUrl; - } - - $properties['gistsUrl'] = $value; - - after_gistsUrl: - - $value = $payload['starred_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'starred_url'; - goto after_starredUrl; - } - - $properties['starredUrl'] = $value; - - after_starredUrl: - - $value = $payload['subscriptions_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'subscriptions_url'; - goto after_subscriptionsUrl; - } - - $properties['subscriptionsUrl'] = $value; - - after_subscriptionsUrl: - - $value = $payload['organizations_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'organizations_url'; - goto after_organizationsUrl; - } - - $properties['organizationsUrl'] = $value; - - after_organizationsUrl: - - $value = $payload['repos_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'repos_url'; - goto after_reposUrl; - } - - $properties['reposUrl'] = $value; - - after_reposUrl: - - $value = $payload['events_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'events_url'; - goto after_eventsUrl; - } - - $properties['eventsUrl'] = $value; - - after_eventsUrl: - - $value = $payload['received_events_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'received_events_url'; - goto after_receivedEventsUrl; - } - - $properties['receivedEventsUrl'] = $value; - - after_receivedEventsUrl: - - $value = $payload['type'] ?? null; - - if ($value === null) { - $missingFields[] = 'type'; - goto after_type; - } - - $properties['type'] = $value; - - after_type: - - $value = $payload['site_admin'] ?? null; - - if ($value === null) { - $missingFields[] = 'site_admin'; - goto after_siteAdmin; - } - - $properties['siteAdmin'] = $value; - - after_siteAdmin: - - $value = $payload['starred_at'] ?? null; - - if ($value === null) { - $properties['starredAt'] = null; - goto after_starredAt; - } - - $properties['starredAt'] = $value; - - after_starredAt: - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\SimpleUser', $exception, stack: $this->hydrationStack); - } - - if (count($missingFields) > 0) { - throw UnableToHydrateObject::dueToMissingFields(SimpleUser::class, $missingFields, stack: $this->hydrationStack); - } - - try { - return new SimpleUser(...$properties); - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\SimpleUser', $exception, stack: $this->hydrationStack); - } - } - private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats(array $payload): Stats { $properties = []; @@ -1031,7 +789,6 @@ public function serializeObjectOfType(object $object, string $className): mixed 'ApiClients\Client\GitHub\Schema\GitUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️GitUser($object), 'ApiClients\Client\GitHub\Schema\Commit\Commit\Tree' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Commit⚡️Tree($object), 'ApiClients\Client\GitHub\Schema\Verification' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Verification($object), - 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($object), 'ApiClients\Client\GitHub\Schema\Commit\Stats' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats($object), 'ApiClients\Client\GitHub\Schema\ValidationError' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️ValidationError($object), 'ApiClients\Client\GitHub\Schema\BasicError' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($object), @@ -1123,21 +880,17 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema after_commit: $result['commit'] = $commit; $author = $object->author; - - if ($author === null) { - goto after_author; - } - - $author = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($author); + $author = match ($author::class) { + 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($author), + 'ApiClients\Client\GitHub\Schema\EmptyObject' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️EmptyObject($author), + }; after_author: $result['author'] = $author; $committer = $object->committer; - - if ($committer === null) { - goto after_committer; - } - - $committer = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($committer); + $committer = match ($committer::class) { + 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($committer), + 'ApiClients\Client\GitHub\Schema\EmptyObject' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️EmptyObject($committer), + }; after_committer: $result['committer'] = $committer; $parents = $object->parents; @@ -1301,97 +1054,6 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema return $result; } - private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser(mixed $object): mixed - { - assert($object instanceof SimpleUser); - $result = []; - - $name = $object->name; - - if ($name === null) { - goto after_name; - } - - after_name: $result['name'] = $name; - - $email = $object->email; - - if ($email === null) { - goto after_email; - } - - after_email: $result['email'] = $email; - - $login = $object->login; - after_login: $result['login'] = $login; - - $id = $object->id; - after_id: $result['id'] = $id; - - $nodeId = $object->nodeId; - after_nodeId: $result['node_id'] = $nodeId; - - $avatarUrl = $object->avatarUrl; - after_avatarUrl: $result['avatar_url'] = $avatarUrl; - - $gravatarId = $object->gravatarId; - - if ($gravatarId === null) { - goto after_gravatarId; - } - - after_gravatarId: $result['gravatar_id'] = $gravatarId; - - $url = $object->url; - after_url: $result['url'] = $url; - - $htmlUrl = $object->htmlUrl; - after_htmlUrl: $result['html_url'] = $htmlUrl; - - $followersUrl = $object->followersUrl; - after_followersUrl: $result['followers_url'] = $followersUrl; - - $followingUrl = $object->followingUrl; - after_followingUrl: $result['following_url'] = $followingUrl; - - $gistsUrl = $object->gistsUrl; - after_gistsUrl: $result['gists_url'] = $gistsUrl; - - $starredUrl = $object->starredUrl; - after_starredUrl: $result['starred_url'] = $starredUrl; - - $subscriptionsUrl = $object->subscriptionsUrl; - after_subscriptionsUrl: $result['subscriptions_url'] = $subscriptionsUrl; - - $organizationsUrl = $object->organizationsUrl; - after_organizationsUrl: $result['organizations_url'] = $organizationsUrl; - - $reposUrl = $object->reposUrl; - after_reposUrl: $result['repos_url'] = $reposUrl; - - $eventsUrl = $object->eventsUrl; - after_eventsUrl: $result['events_url'] = $eventsUrl; - - $receivedEventsUrl = $object->receivedEventsUrl; - after_receivedEventsUrl: $result['received_events_url'] = $receivedEventsUrl; - - $type = $object->type; - after_type: $result['type'] = $type; - - $siteAdmin = $object->siteAdmin; - after_siteAdmin: $result['site_admin'] = $siteAdmin; - - $starredAt = $object->starredAt; - - if ($starredAt === null) { - goto after_starredAt; - } - - after_starredAt: $result['starred_at'] = $starredAt; - - return $result; - } - private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats(mixed $object): mixed { assert($object instanceof Stats); diff --git a/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Compare/Basehead.php b/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Compare/Basehead.php index 6169ccfb95b..3143bf424ea 100644 --- a/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Compare/Basehead.php +++ b/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Compare/Basehead.php @@ -4,6 +4,8 @@ namespace ApiClients\Client\GitHub\Internal\Hydrator\Operation\Repos\Owner\Repo\Compare; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Author; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Committer; use ApiClients\Client\GitHub\Schema\BasicError; use ApiClients\Client\GitHub\Schema\Commit; use ApiClients\Client\GitHub\Schema\Commit\Commit\Tree; @@ -11,7 +13,6 @@ use ApiClients\Client\GitHub\Schema\CommitComparison; use ApiClients\Client\GitHub\Schema\GitUser; use ApiClients\Client\GitHub\Schema\Operations\SecretScanning\ListAlertsForEnterprise\Response\ApplicationJson\ServiceUnavailable; -use ApiClients\Client\GitHub\Schema\SimpleUser; use ApiClients\Client\GitHub\Schema\Verification; use EventSauce\ObjectHydrator\IterableList; use EventSauce\ObjectHydrator\ObjectMapper; @@ -54,7 +55,6 @@ public function hydrateObject(string $className, array $payload): object 'ApiClients\Client\GitHub\Schema\GitUser' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️GitUser($payload), 'ApiClients\Client\GitHub\Schema\Commit\Commit\Tree' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Commit⚡️Tree($payload), 'ApiClients\Client\GitHub\Schema\Verification' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Verification($payload), - 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($payload), 'ApiClients\Client\GitHub\Schema\Commit\Stats' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats($payload), 'ApiClients\Client\GitHub\Schema\BasicError' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($payload), 'ApiClients\Client\GitHub\Schema\Operations\SecretScanning\ListAlertsForEnterprise\Response\ApplicationJson\ServiceUnavailable' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Operations⚡️SecretScanning⚡️ListAlertsForEnterprise⚡️Response⚡️ApplicationJson⚡️ServiceUnavailable($payload), @@ -325,17 +325,21 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Comm $value = $payload['author'] ?? null; if ($value === null) { - $properties['author'] = null; + $missingFields[] = 'author'; goto after_author; } - if (is_array($value)) { - try { - $this->hydrationStack[] = 'author'; - $value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($value); - } finally { - array_pop($this->hydrationStack); - } + static $authorCaster1; + + if ($authorCaster1 === null) { + $authorCaster1 = new Author(...[]); + } + + $value = $authorCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'author'; + goto after_author; } $properties['author'] = $value; @@ -345,17 +349,21 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Comm $value = $payload['committer'] ?? null; if ($value === null) { - $properties['committer'] = null; + $missingFields[] = 'committer'; goto after_committer; } - if (is_array($value)) { - try { - $this->hydrationStack[] = 'committer'; - $value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($value); - } finally { - array_pop($this->hydrationStack); - } + static $committerCaster1; + + if ($committerCaster1 === null) { + $committerCaster1 = new Committer(...[]); + } + + $value = $committerCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'committer'; + goto after_committer; } $properties['committer'] = $value; @@ -706,256 +714,6 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Veri } } - private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser(array $payload): SimpleUser - { - $properties = []; - $missingFields = []; - try { - $value = $payload['name'] ?? null; - - if ($value === null) { - $properties['name'] = null; - goto after_name; - } - - $properties['name'] = $value; - - after_name: - - $value = $payload['email'] ?? null; - - if ($value === null) { - $properties['email'] = null; - goto after_email; - } - - $properties['email'] = $value; - - after_email: - - $value = $payload['login'] ?? null; - - if ($value === null) { - $missingFields[] = 'login'; - goto after_login; - } - - $properties['login'] = $value; - - after_login: - - $value = $payload['id'] ?? null; - - if ($value === null) { - $missingFields[] = 'id'; - goto after_id; - } - - $properties['id'] = $value; - - after_id: - - $value = $payload['node_id'] ?? null; - - if ($value === null) { - $missingFields[] = 'node_id'; - goto after_nodeId; - } - - $properties['nodeId'] = $value; - - after_nodeId: - - $value = $payload['avatar_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'avatar_url'; - goto after_avatarUrl; - } - - $properties['avatarUrl'] = $value; - - after_avatarUrl: - - $value = $payload['gravatar_id'] ?? null; - - if ($value === null) { - $properties['gravatarId'] = null; - goto after_gravatarId; - } - - $properties['gravatarId'] = $value; - - after_gravatarId: - - $value = $payload['url'] ?? null; - - if ($value === null) { - $missingFields[] = 'url'; - goto after_url; - } - - $properties['url'] = $value; - - after_url: - - $value = $payload['html_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'html_url'; - goto after_htmlUrl; - } - - $properties['htmlUrl'] = $value; - - after_htmlUrl: - - $value = $payload['followers_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'followers_url'; - goto after_followersUrl; - } - - $properties['followersUrl'] = $value; - - after_followersUrl: - - $value = $payload['following_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'following_url'; - goto after_followingUrl; - } - - $properties['followingUrl'] = $value; - - after_followingUrl: - - $value = $payload['gists_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'gists_url'; - goto after_gistsUrl; - } - - $properties['gistsUrl'] = $value; - - after_gistsUrl: - - $value = $payload['starred_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'starred_url'; - goto after_starredUrl; - } - - $properties['starredUrl'] = $value; - - after_starredUrl: - - $value = $payload['subscriptions_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'subscriptions_url'; - goto after_subscriptionsUrl; - } - - $properties['subscriptionsUrl'] = $value; - - after_subscriptionsUrl: - - $value = $payload['organizations_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'organizations_url'; - goto after_organizationsUrl; - } - - $properties['organizationsUrl'] = $value; - - after_organizationsUrl: - - $value = $payload['repos_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'repos_url'; - goto after_reposUrl; - } - - $properties['reposUrl'] = $value; - - after_reposUrl: - - $value = $payload['events_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'events_url'; - goto after_eventsUrl; - } - - $properties['eventsUrl'] = $value; - - after_eventsUrl: - - $value = $payload['received_events_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'received_events_url'; - goto after_receivedEventsUrl; - } - - $properties['receivedEventsUrl'] = $value; - - after_receivedEventsUrl: - - $value = $payload['type'] ?? null; - - if ($value === null) { - $missingFields[] = 'type'; - goto after_type; - } - - $properties['type'] = $value; - - after_type: - - $value = $payload['site_admin'] ?? null; - - if ($value === null) { - $missingFields[] = 'site_admin'; - goto after_siteAdmin; - } - - $properties['siteAdmin'] = $value; - - after_siteAdmin: - - $value = $payload['starred_at'] ?? null; - - if ($value === null) { - $properties['starredAt'] = null; - goto after_starredAt; - } - - $properties['starredAt'] = $value; - - after_starredAt: - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\SimpleUser', $exception, stack: $this->hydrationStack); - } - - if (count($missingFields) > 0) { - throw UnableToHydrateObject::dueToMissingFields(SimpleUser::class, $missingFields, stack: $this->hydrationStack); - } - - try { - return new SimpleUser(...$properties); - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\SimpleUser', $exception, stack: $this->hydrationStack); - } - } - private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats(array $payload): Stats { $properties = []; @@ -1160,7 +918,6 @@ public function serializeObjectOfType(object $object, string $className): mixed 'ApiClients\Client\GitHub\Schema\GitUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️GitUser($object), 'ApiClients\Client\GitHub\Schema\Commit\Commit\Tree' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Commit⚡️Tree($object), 'ApiClients\Client\GitHub\Schema\Verification' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Verification($object), - 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($object), 'ApiClients\Client\GitHub\Schema\Commit\Stats' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats($object), 'ApiClients\Client\GitHub\Schema\BasicError' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($object), 'ApiClients\Client\GitHub\Schema\Operations\SecretScanning\ListAlertsForEnterprise\Response\ApplicationJson\ServiceUnavailable' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Operations⚡️SecretScanning⚡️ListAlertsForEnterprise⚡️Response⚡️ApplicationJson⚡️ServiceUnavailable($object), @@ -1319,21 +1076,17 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema after_commit: $result['commit'] = $commit; $author = $object->author; - - if ($author === null) { - goto after_author; - } - - $author = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($author); + $author = match ($author::class) { + 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($author), + 'ApiClients\Client\GitHub\Schema\EmptyObject' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️EmptyObject($author), + }; after_author: $result['author'] = $author; $committer = $object->committer; - - if ($committer === null) { - goto after_committer; - } - - $committer = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($committer); + $committer = match ($committer::class) { + 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($committer), + 'ApiClients\Client\GitHub\Schema\EmptyObject' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️EmptyObject($committer), + }; after_committer: $result['committer'] = $committer; $parents = $object->parents; @@ -1497,97 +1250,6 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema return $result; } - private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser(mixed $object): mixed - { - assert($object instanceof SimpleUser); - $result = []; - - $name = $object->name; - - if ($name === null) { - goto after_name; - } - - after_name: $result['name'] = $name; - - $email = $object->email; - - if ($email === null) { - goto after_email; - } - - after_email: $result['email'] = $email; - - $login = $object->login; - after_login: $result['login'] = $login; - - $id = $object->id; - after_id: $result['id'] = $id; - - $nodeId = $object->nodeId; - after_nodeId: $result['node_id'] = $nodeId; - - $avatarUrl = $object->avatarUrl; - after_avatarUrl: $result['avatar_url'] = $avatarUrl; - - $gravatarId = $object->gravatarId; - - if ($gravatarId === null) { - goto after_gravatarId; - } - - after_gravatarId: $result['gravatar_id'] = $gravatarId; - - $url = $object->url; - after_url: $result['url'] = $url; - - $htmlUrl = $object->htmlUrl; - after_htmlUrl: $result['html_url'] = $htmlUrl; - - $followersUrl = $object->followersUrl; - after_followersUrl: $result['followers_url'] = $followersUrl; - - $followingUrl = $object->followingUrl; - after_followingUrl: $result['following_url'] = $followingUrl; - - $gistsUrl = $object->gistsUrl; - after_gistsUrl: $result['gists_url'] = $gistsUrl; - - $starredUrl = $object->starredUrl; - after_starredUrl: $result['starred_url'] = $starredUrl; - - $subscriptionsUrl = $object->subscriptionsUrl; - after_subscriptionsUrl: $result['subscriptions_url'] = $subscriptionsUrl; - - $organizationsUrl = $object->organizationsUrl; - after_organizationsUrl: $result['organizations_url'] = $organizationsUrl; - - $reposUrl = $object->reposUrl; - after_reposUrl: $result['repos_url'] = $reposUrl; - - $eventsUrl = $object->eventsUrl; - after_eventsUrl: $result['events_url'] = $eventsUrl; - - $receivedEventsUrl = $object->receivedEventsUrl; - after_receivedEventsUrl: $result['received_events_url'] = $receivedEventsUrl; - - $type = $object->type; - after_type: $result['type'] = $type; - - $siteAdmin = $object->siteAdmin; - after_siteAdmin: $result['site_admin'] = $siteAdmin; - - $starredAt = $object->starredAt; - - if ($starredAt === null) { - goto after_starredAt; - } - - after_starredAt: $result['starred_at'] = $starredAt; - - return $result; - } - private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats(mixed $object): mixed { assert($object instanceof Stats); diff --git a/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Merges.php b/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Merges.php index c69585ffe07..84100a6f1e0 100644 --- a/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Merges.php +++ b/clients/GitHub/src/Internal/Hydrator/Operation/Repos/Owner/Repo/Merges.php @@ -4,12 +4,13 @@ namespace ApiClients\Client\GitHub\Internal\Hydrator\Operation\Repos\Owner\Repo; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Author; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Committer; use ApiClients\Client\GitHub\Schema\BasicError; use ApiClients\Client\GitHub\Schema\Commit; use ApiClients\Client\GitHub\Schema\Commit\Commit\Tree; use ApiClients\Client\GitHub\Schema\Commit\Stats; use ApiClients\Client\GitHub\Schema\GitUser; -use ApiClients\Client\GitHub\Schema\SimpleUser; use ApiClients\Client\GitHub\Schema\ValidationError; use ApiClients\Client\GitHub\Schema\Verification; use EventSauce\ObjectHydrator\IterableList; @@ -52,7 +53,6 @@ public function hydrateObject(string $className, array $payload): object 'ApiClients\Client\GitHub\Schema\GitUser' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️GitUser($payload), 'ApiClients\Client\GitHub\Schema\Commit\Commit\Tree' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Commit⚡️Tree($payload), 'ApiClients\Client\GitHub\Schema\Verification' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Verification($payload), - 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($payload), 'ApiClients\Client\GitHub\Schema\Commit\Stats' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats($payload), 'ApiClients\Client\GitHub\Schema\BasicError' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($payload), 'ApiClients\Client\GitHub\Schema\ValidationError' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️ValidationError($payload), @@ -143,17 +143,21 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Comm $value = $payload['author'] ?? null; if ($value === null) { - $properties['author'] = null; + $missingFields[] = 'author'; goto after_author; } - if (is_array($value)) { - try { - $this->hydrationStack[] = 'author'; - $value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($value); - } finally { - array_pop($this->hydrationStack); - } + static $authorCaster1; + + if ($authorCaster1 === null) { + $authorCaster1 = new Author(...[]); + } + + $value = $authorCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'author'; + goto after_author; } $properties['author'] = $value; @@ -163,17 +167,21 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Comm $value = $payload['committer'] ?? null; if ($value === null) { - $properties['committer'] = null; + $missingFields[] = 'committer'; goto after_committer; } - if (is_array($value)) { - try { - $this->hydrationStack[] = 'committer'; - $value = $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($value); - } finally { - array_pop($this->hydrationStack); - } + static $committerCaster1; + + if ($committerCaster1 === null) { + $committerCaster1 = new Committer(...[]); + } + + $value = $committerCaster1->cast($value, $this); + + if ($value === null) { + $missingFields[] = 'committer'; + goto after_committer; } $properties['committer'] = $value; @@ -524,256 +532,6 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Veri } } - private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser(array $payload): SimpleUser - { - $properties = []; - $missingFields = []; - try { - $value = $payload['name'] ?? null; - - if ($value === null) { - $properties['name'] = null; - goto after_name; - } - - $properties['name'] = $value; - - after_name: - - $value = $payload['email'] ?? null; - - if ($value === null) { - $properties['email'] = null; - goto after_email; - } - - $properties['email'] = $value; - - after_email: - - $value = $payload['login'] ?? null; - - if ($value === null) { - $missingFields[] = 'login'; - goto after_login; - } - - $properties['login'] = $value; - - after_login: - - $value = $payload['id'] ?? null; - - if ($value === null) { - $missingFields[] = 'id'; - goto after_id; - } - - $properties['id'] = $value; - - after_id: - - $value = $payload['node_id'] ?? null; - - if ($value === null) { - $missingFields[] = 'node_id'; - goto after_nodeId; - } - - $properties['nodeId'] = $value; - - after_nodeId: - - $value = $payload['avatar_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'avatar_url'; - goto after_avatarUrl; - } - - $properties['avatarUrl'] = $value; - - after_avatarUrl: - - $value = $payload['gravatar_id'] ?? null; - - if ($value === null) { - $properties['gravatarId'] = null; - goto after_gravatarId; - } - - $properties['gravatarId'] = $value; - - after_gravatarId: - - $value = $payload['url'] ?? null; - - if ($value === null) { - $missingFields[] = 'url'; - goto after_url; - } - - $properties['url'] = $value; - - after_url: - - $value = $payload['html_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'html_url'; - goto after_htmlUrl; - } - - $properties['htmlUrl'] = $value; - - after_htmlUrl: - - $value = $payload['followers_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'followers_url'; - goto after_followersUrl; - } - - $properties['followersUrl'] = $value; - - after_followersUrl: - - $value = $payload['following_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'following_url'; - goto after_followingUrl; - } - - $properties['followingUrl'] = $value; - - after_followingUrl: - - $value = $payload['gists_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'gists_url'; - goto after_gistsUrl; - } - - $properties['gistsUrl'] = $value; - - after_gistsUrl: - - $value = $payload['starred_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'starred_url'; - goto after_starredUrl; - } - - $properties['starredUrl'] = $value; - - after_starredUrl: - - $value = $payload['subscriptions_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'subscriptions_url'; - goto after_subscriptionsUrl; - } - - $properties['subscriptionsUrl'] = $value; - - after_subscriptionsUrl: - - $value = $payload['organizations_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'organizations_url'; - goto after_organizationsUrl; - } - - $properties['organizationsUrl'] = $value; - - after_organizationsUrl: - - $value = $payload['repos_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'repos_url'; - goto after_reposUrl; - } - - $properties['reposUrl'] = $value; - - after_reposUrl: - - $value = $payload['events_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'events_url'; - goto after_eventsUrl; - } - - $properties['eventsUrl'] = $value; - - after_eventsUrl: - - $value = $payload['received_events_url'] ?? null; - - if ($value === null) { - $missingFields[] = 'received_events_url'; - goto after_receivedEventsUrl; - } - - $properties['receivedEventsUrl'] = $value; - - after_receivedEventsUrl: - - $value = $payload['type'] ?? null; - - if ($value === null) { - $missingFields[] = 'type'; - goto after_type; - } - - $properties['type'] = $value; - - after_type: - - $value = $payload['site_admin'] ?? null; - - if ($value === null) { - $missingFields[] = 'site_admin'; - goto after_siteAdmin; - } - - $properties['siteAdmin'] = $value; - - after_siteAdmin: - - $value = $payload['starred_at'] ?? null; - - if ($value === null) { - $properties['starredAt'] = null; - goto after_starredAt; - } - - $properties['starredAt'] = $value; - - after_starredAt: - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\SimpleUser', $exception, stack: $this->hydrationStack); - } - - if (count($missingFields) > 0) { - throw UnableToHydrateObject::dueToMissingFields(SimpleUser::class, $missingFields, stack: $this->hydrationStack); - } - - try { - return new SimpleUser(...$properties); - } catch (Throwable $exception) { - throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\SimpleUser', $exception, stack: $this->hydrationStack); - } - } - private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats(array $payload): Stats { $properties = []; @@ -977,7 +735,6 @@ public function serializeObjectOfType(object $object, string $className): mixed 'ApiClients\Client\GitHub\Schema\GitUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️GitUser($object), 'ApiClients\Client\GitHub\Schema\Commit\Commit\Tree' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Commit⚡️Tree($object), 'ApiClients\Client\GitHub\Schema\Verification' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Verification($object), - 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($object), 'ApiClients\Client\GitHub\Schema\Commit\Stats' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats($object), 'ApiClients\Client\GitHub\Schema\BasicError' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($object), 'ApiClients\Client\GitHub\Schema\ValidationError' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️ValidationError($object), @@ -1068,21 +825,17 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema after_commit: $result['commit'] = $commit; $author = $object->author; - - if ($author === null) { - goto after_author; - } - - $author = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($author); + $author = match ($author::class) { + 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($author), + 'ApiClients\Client\GitHub\Schema\EmptyObject' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️EmptyObject($author), + }; after_author: $result['author'] = $author; $committer = $object->committer; - - if ($committer === null) { - goto after_committer; - } - - $committer = $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($committer); + $committer = match ($committer::class) { + 'ApiClients\Client\GitHub\Schema\SimpleUser' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser($committer), + 'ApiClients\Client\GitHub\Schema\EmptyObject' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️EmptyObject($committer), + }; after_committer: $result['committer'] = $committer; $parents = $object->parents; @@ -1246,97 +999,6 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema return $result; } - private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️SimpleUser(mixed $object): mixed - { - assert($object instanceof SimpleUser); - $result = []; - - $name = $object->name; - - if ($name === null) { - goto after_name; - } - - after_name: $result['name'] = $name; - - $email = $object->email; - - if ($email === null) { - goto after_email; - } - - after_email: $result['email'] = $email; - - $login = $object->login; - after_login: $result['login'] = $login; - - $id = $object->id; - after_id: $result['id'] = $id; - - $nodeId = $object->nodeId; - after_nodeId: $result['node_id'] = $nodeId; - - $avatarUrl = $object->avatarUrl; - after_avatarUrl: $result['avatar_url'] = $avatarUrl; - - $gravatarId = $object->gravatarId; - - if ($gravatarId === null) { - goto after_gravatarId; - } - - after_gravatarId: $result['gravatar_id'] = $gravatarId; - - $url = $object->url; - after_url: $result['url'] = $url; - - $htmlUrl = $object->htmlUrl; - after_htmlUrl: $result['html_url'] = $htmlUrl; - - $followersUrl = $object->followersUrl; - after_followersUrl: $result['followers_url'] = $followersUrl; - - $followingUrl = $object->followingUrl; - after_followingUrl: $result['following_url'] = $followingUrl; - - $gistsUrl = $object->gistsUrl; - after_gistsUrl: $result['gists_url'] = $gistsUrl; - - $starredUrl = $object->starredUrl; - after_starredUrl: $result['starred_url'] = $starredUrl; - - $subscriptionsUrl = $object->subscriptionsUrl; - after_subscriptionsUrl: $result['subscriptions_url'] = $subscriptionsUrl; - - $organizationsUrl = $object->organizationsUrl; - after_organizationsUrl: $result['organizations_url'] = $organizationsUrl; - - $reposUrl = $object->reposUrl; - after_reposUrl: $result['repos_url'] = $reposUrl; - - $eventsUrl = $object->eventsUrl; - after_eventsUrl: $result['events_url'] = $eventsUrl; - - $receivedEventsUrl = $object->receivedEventsUrl; - after_receivedEventsUrl: $result['received_events_url'] = $receivedEventsUrl; - - $type = $object->type; - after_type: $result['type'] = $type; - - $siteAdmin = $object->siteAdmin; - after_siteAdmin: $result['site_admin'] = $siteAdmin; - - $starredAt = $object->starredAt; - - if ($starredAt === null) { - goto after_starredAt; - } - - after_starredAt: $result['starred_at'] = $starredAt; - - return $result; - } - private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Commit⚡️Stats(mixed $object): mixed { assert($object instanceof Stats); diff --git a/clients/GitHub/src/Internal/Operator/Orgs/AddSecurityManagerTeam.php b/clients/GitHub/src/Internal/Operator/Orgs/AddSecurityManagerTeam.php index 150e3ad507a..5cb19e25ff4 100644 --- a/clients/GitHub/src/Internal/Operator/Orgs/AddSecurityManagerTeam.php +++ b/clients/GitHub/src/Internal/Operator/Orgs/AddSecurityManagerTeam.php @@ -22,6 +22,7 @@ public function __construct(private Browser $browser, private AuthenticationInte { } + /** @return */ public function call(string $org, string $teamSlug): WithoutBody { $operation = new \ApiClients\Client\GitHub\Internal\Operation\Orgs\AddSecurityManagerTeam($org, $teamSlug); diff --git a/clients/GitHub/src/Internal/Router/Put/Orgs.php b/clients/GitHub/src/Internal/Router/Put/Orgs.php index b9f1e2d71f5..220c83e78dc 100644 --- a/clients/GitHub/src/Internal/Router/Put/Orgs.php +++ b/clients/GitHub/src/Internal/Router/Put/Orgs.php @@ -181,6 +181,7 @@ public function createOrUpdateCustomProperty(array $params): OrgCustomProperty return $operator->call($arguments['org'], $arguments['custom_property_name'], $params); } + /** @return */ public function addSecurityManagerTeam(array $params): WithoutBody { $arguments = []; diff --git a/clients/GitHub/src/Internal/Router/Put/Six.php b/clients/GitHub/src/Internal/Router/Put/Six.php index 57cb6d21c98..0b6b15af585 100644 --- a/clients/GitHub/src/Internal/Router/Put/Six.php +++ b/clients/GitHub/src/Internal/Router/Put/Six.php @@ -20,7 +20,6 @@ public function __construct(private Routers $routers) { } - /** @return |\ApiClients\Tools\OpenApiClient\Utils\Response\WithoutBody */ public function call(string $call, array $params, array $pathChunks): WithoutBody|EmptyObject|OrgCustomProperty|RepositoryInvitation|FileCommit|Environment|RepositoryRuleset { if ($pathChunks[0] === '') { diff --git a/clients/GitHub/src/Operation/Orgs.php b/clients/GitHub/src/Operation/Orgs.php index 555f6008d6c..f73e89deb73 100644 --- a/clients/GitHub/src/Operation/Orgs.php +++ b/clients/GitHub/src/Operation/Orgs.php @@ -528,6 +528,7 @@ public function listSecurityManagerTeams(string $org): iterable return $this->operators->orgs👷ListSecurityManagerTeams()->call($org); } + /** @return */ public function addSecurityManagerTeam(string $org, string $teamSlug): WithoutBody { return $this->operators->orgs👷AddSecurityManagerTeam()->call($org, $teamSlug); diff --git a/clients/GitHub/src/PHPStan/ClientCallReturnTypes.php b/clients/GitHub/src/PHPStan/ClientCallReturnTypes.php index 2b0ac75b43c..5beb1d03305 100644 --- a/clients/GitHub/src/PHPStan/ClientCallReturnTypes.php +++ b/clients/GitHub/src/PHPStan/ClientCallReturnTypes.php @@ -1344,7 +1344,7 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method } if ($call === 'PUT /orgs/{org}/security-managers/teams/{team_slug}') { - return $this->typeResolver->resolve('\\ApiClients\\Tools\\OpenApiClient\\Utils\\Response\\WithoutBody'); + return $this->typeResolver->resolve(''); } if ($call === 'DELETE /orgs/{org}/security-managers/teams/{team_slug}') { diff --git a/clients/GitHub/src/Schema/BranchWithProtection.php b/clients/GitHub/src/Schema/BranchWithProtection.php index b6b0f86a6c5..58da87c1e73 100644 --- a/clients/GitHub/src/Schema/BranchWithProtection.php +++ b/clients/GitHub/src/Schema/BranchWithProtection.php @@ -221,10 +221,11 @@ } }, "author": { - "anyOf": [ - { - "type": "null" - }, + "type": [ + "null", + "object" + ], + "oneOf": [ { "title": "Simple User", "required": [ @@ -386,14 +387,22 @@ } }, "description": "A GitHub user." + }, + { + "title": "Empty Object", + "type": "object", + "properties": {}, + "description": "An object without any properties.", + "additionalProperties": false } ] }, "committer": { - "anyOf": [ - { - "type": "null" - }, + "type": [ + "null", + "object" + ], + "oneOf": [ { "title": "Simple User", "required": [ @@ -555,6 +564,13 @@ } }, "description": "A GitHub user." + }, + { + "title": "Empty Object", + "type": "object", + "properties": {}, + "description": "An object without any properties.", + "additionalProperties": false } ] }, @@ -2774,52 +2790,8 @@ "signature": "generated" } }, - "author": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, - "committer": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, + "author": null, + "committer": null, "parents": [ { "sha": "7638417db6d59f3c431d3e1f261cc637155684cd", diff --git a/clients/GitHub/src/Schema/Commit.php b/clients/GitHub/src/Schema/Commit.php index c205e768e8f..d783c53ae9f 100644 --- a/clients/GitHub/src/Schema/Commit.php +++ b/clients/GitHub/src/Schema/Commit.php @@ -4,6 +4,8 @@ namespace ApiClients\Client\GitHub\Schema; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Author; +use ApiClients\Client\GitHub\Internal\Attribute\CastUnionToType\Schema\Commit\Committer; use ApiClients\Client\GitHub\Schema; use EventSauce\ObjectHydrator\MapFrom; @@ -206,10 +208,11 @@ } }, "author": { - "anyOf": [ - { - "type": "null" - }, + "type": [ + "null", + "object" + ], + "oneOf": [ { "title": "Simple User", "required": [ @@ -371,14 +374,22 @@ } }, "description": "A GitHub user." + }, + { + "title": "Empty Object", + "type": "object", + "properties": {}, + "description": "An object without any properties.", + "additionalProperties": false } ] }, "committer": { - "anyOf": [ - { - "type": "null" - }, + "type": [ + "null", + "object" + ], + "oneOf": [ { "title": "Simple User", "required": [ @@ -540,6 +551,13 @@ } }, "description": "A GitHub user." + }, + { + "title": "Empty Object", + "type": "object", + "properties": {}, + "description": "An object without any properties.", + "additionalProperties": false } ] }, @@ -724,52 +742,8 @@ "signature": "generated" } }, - "author": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, - "committer": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, + "author": null, + "committer": null, "parents": [ { "sha": "7638417db6d59f3c431d3e1f261cc637155684cd", @@ -820,7 +794,9 @@ public function __construct(public string $url, public string $sha, #[MapFrom('node_id')] public string $nodeId, #[MapFrom('html_url')] public string $htmlUrl, #[MapFrom('comments_url')] - public string $commentsUrl, public Schema\Commit\Commit $commit, public Schema\SimpleUser|null $author, public Schema\SimpleUser|null $committer, public array $parents, public Schema\Commit\Stats|null $stats, public array|null $files,) + public string $commentsUrl, public Schema\Commit\Commit $commit, #[Author] + public Schema\SimpleUser|Schema\EmptyObject $author, #[Committer] + public Schema\SimpleUser|Schema\EmptyObject $committer, public array $parents, public Schema\Commit\Stats|null $stats, public array|null $files,) { } } diff --git a/clients/GitHub/src/Schema/CommitComparison.php b/clients/GitHub/src/Schema/CommitComparison.php index e711aa75284..8405301da1f 100644 --- a/clients/GitHub/src/Schema/CommitComparison.php +++ b/clients/GitHub/src/Schema/CommitComparison.php @@ -259,10 +259,11 @@ } }, "author": { - "anyOf": [ - { - "type": "null" - }, + "type": [ + "null", + "object" + ], + "oneOf": [ { "title": "Simple User", "required": [ @@ -424,14 +425,22 @@ } }, "description": "A GitHub user." + }, + { + "title": "Empty Object", + "type": "object", + "properties": {}, + "description": "An object without any properties.", + "additionalProperties": false } ] }, "committer": { - "anyOf": [ - { - "type": "null" - }, + "type": [ + "null", + "object" + ], + "oneOf": [ { "title": "Simple User", "required": [ @@ -593,6 +602,13 @@ } }, "description": "A GitHub user." + }, + { + "title": "Empty Object", + "type": "object", + "properties": {}, + "description": "An object without any properties.", + "additionalProperties": false } ] }, @@ -941,10 +957,11 @@ } }, "author": { - "anyOf": [ - { - "type": "null" - }, + "type": [ + "null", + "object" + ], + "oneOf": [ { "title": "Simple User", "required": [ @@ -1106,14 +1123,22 @@ } }, "description": "A GitHub user." + }, + { + "title": "Empty Object", + "type": "object", + "properties": {}, + "description": "An object without any properties.", + "additionalProperties": false } ] }, "committer": { - "anyOf": [ - { - "type": "null" - }, + "type": [ + "null", + "object" + ], + "oneOf": [ { "title": "Simple User", "required": [ @@ -1275,6 +1300,13 @@ } }, "description": "A GitHub user." + }, + { + "title": "Empty Object", + "type": "object", + "properties": {}, + "description": "An object without any properties.", + "additionalProperties": false } ] }, @@ -1655,10 +1687,11 @@ } }, "author": { - "anyOf": [ - { - "type": "null" - }, + "type": [ + "null", + "object" + ], + "oneOf": [ { "title": "Simple User", "required": [ @@ -1820,14 +1853,22 @@ } }, "description": "A GitHub user." + }, + { + "title": "Empty Object", + "type": "object", + "properties": {}, + "description": "An object without any properties.", + "additionalProperties": false } ] }, "committer": { - "anyOf": [ - { - "type": "null" - }, + "type": [ + "null", + "object" + ], + "oneOf": [ { "title": "Simple User", "required": [ @@ -1989,6 +2030,13 @@ } }, "description": "A GitHub user." + }, + { + "title": "Empty Object", + "type": "object", + "properties": {}, + "description": "An object without any properties.", + "additionalProperties": false } ] }, @@ -2282,52 +2330,8 @@ "signature": "generated" } }, - "author": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, - "committer": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, + "author": null, + "committer": null, "parents": [ { "sha": "7638417db6d59f3c431d3e1f261cc637155684cd", @@ -2405,52 +2409,8 @@ "signature": "generated" } }, - "author": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, - "committer": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, + "author": null, + "committer": null, "parents": [ { "sha": "7638417db6d59f3c431d3e1f261cc637155684cd", @@ -2533,52 +2493,8 @@ "signature": "generated" } }, - "author": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, - "committer": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, + "author": null, + "committer": null, "parents": [ { "sha": "7638417db6d59f3c431d3e1f261cc637155684cd", @@ -2656,52 +2572,8 @@ "signature": "generated" } }, - "author": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, - "committer": { - "name": "generated", - "email": "generated", - "login": "octocat", - "id": 1, - "node_id": "MDQ6VXNlcjE=", - "avatar_url": "https:\\/\\/github.com\\/images\\/error\\/octocat_happy.gif", - "gravatar_id": "41d064eb2195891e12d0413f63227ea7", - "url": "https:\\/\\/api.github.com\\/users\\/octocat", - "html_url": "https:\\/\\/github.com\\/octocat", - "followers_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/followers", - "following_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/following{\\/other_user}", - "gists_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/gists{\\/gist_id}", - "starred_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/starred{\\/owner}{\\/repo}", - "subscriptions_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/subscriptions", - "organizations_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/orgs", - "repos_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/repos", - "events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/events{\\/privacy}", - "received_events_url": "https:\\/\\/api.github.com\\/users\\/octocat\\/received_events", - "type": "User", - "site_admin": false, - "starred_at": "\\"2020-07-09T00:17:55Z\\"" - }, + "author": null, + "committer": null, "parents": [ { "sha": "7638417db6d59f3c431d3e1f261cc637155684cd", diff --git a/clients/GitHub/tests/Types/ClientCallReturnTypes.php b/clients/GitHub/tests/Types/ClientCallReturnTypes.php index 91ba7da6f78..377c21ffe8e 100644 --- a/clients/GitHub/tests/Types/ClientCallReturnTypes.php +++ b/clients/GitHub/tests/Types/ClientCallReturnTypes.php @@ -342,7 +342,7 @@ function authHeader(): string assertType('Observable', $client->call('LIST /orgs/{org}/secret-scanning/alerts')); assertType('Observable', $client->call('GET /orgs/{org}/security-advisories')); assertType('Observable', $client->call('GET /orgs/{org}/security-managers')); -assertType('\\ApiClients\\Tools\\OpenApiClient\\Utils\\Response\\WithoutBody', $client->call('PUT /orgs/{org}/security-managers/teams/{team_slug}')); +assertType('', $client->call('PUT /orgs/{org}/security-managers/teams/{team_slug}')); assertType('', $client->call('DELETE /orgs/{org}/security-managers/teams/{team_slug}')); assertType('', $client->call('GET /orgs/{org}/settings/billing/actions')); assertType('', $client->call('GET /orgs/{org}/settings/billing/packages')); diff --git a/etc/specs/GitHub/current.spec.yaml b/etc/specs/GitHub/current.spec.yaml index b217cec1495..f369d1321de 100644 --- a/etc/specs/GitHub/current.spec.yaml +++ b/etc/specs/GitHub/current.spec.yaml @@ -78115,13 +78115,19 @@ components: - tree - url author: - anyOf: - - type: 'null' + oneOf: - "$ref": "#/components/schemas/simple-user" + - "$ref": "#/components/schemas/empty-object" + type: + - 'null' + - object committer: - anyOf: - - type: 'null' + oneOf: - "$ref": "#/components/schemas/simple-user" + - "$ref": "#/components/schemas/empty-object" + type: + - 'null' + - object parents: type: array items: