Skip to content

Commit 95efa1d

Browse files
authored
Merge pull request #1346 from php-api-clients/GitHub/from-1.1.4-2b790a7412799c3a2996ba936824dd7d-from-1.1.4-2b790a7412799c3a2996ba936824dd7d
2 parents 1edc10f + 4cef930 commit 95efa1d

Some content is hidden

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

42 files changed

+255
-120
lines changed

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

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

clients/GitHub/src/Internal/Hydrator/Operation/User/Following/Username.php

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace ApiClients\Client\GitHub\Internal\Hydrator\Operation\User\Following;
66

77
use ApiClients\Client\GitHub\Schema\BasicError;
8+
use ApiClients\Client\GitHub\Schema\ValidationError;
89
use EventSauce\ObjectHydrator\IterableList;
910
use EventSauce\ObjectHydrator\ObjectMapper;
1011
use EventSauce\ObjectHydrator\PropertySerializers\SerializeArrayItems;
@@ -39,6 +40,7 @@ public function hydrateObject(string $className, array $payload): object
3940
{
4041
return match ($className) {
4142
'ApiClients\Client\GitHub\Schema\BasicError' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($payload),
43+
'ApiClients\Client\GitHub\Schema\ValidationError' => $this->hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️ValidationError($payload),
4244
default => throw UnableToHydrateObject::noHydrationDefined($className, $this->hydrationStack),
4345
};
4446
}
@@ -106,6 +108,58 @@ private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️Basi
106108
}
107109
}
108110

111+
private function hydrateApiClients⚡️Client⚡️GitHub⚡️Schema⚡️ValidationError(array $payload): ValidationError
112+
{
113+
$properties = [];
114+
$missingFields = [];
115+
try {
116+
$value = $payload['message'] ?? null;
117+
118+
if ($value === null) {
119+
$missingFields[] = 'message';
120+
goto after_message;
121+
}
122+
123+
$properties['message'] = $value;
124+
125+
after_message:
126+
127+
$value = $payload['documentation_url'] ?? null;
128+
129+
if ($value === null) {
130+
$missingFields[] = 'documentation_url';
131+
goto after_documentationUrl;
132+
}
133+
134+
$properties['documentationUrl'] = $value;
135+
136+
after_documentationUrl:
137+
138+
$value = $payload['errors'] ?? null;
139+
140+
if ($value === null) {
141+
$properties['errors'] = null;
142+
goto after_errors;
143+
}
144+
145+
$properties['errors'] = $value;
146+
147+
after_errors:
148+
} catch (Throwable $exception) {
149+
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\ValidationError', $exception, stack: $this->hydrationStack);
150+
}
151+
152+
if (count($missingFields) > 0) {
153+
throw UnableToHydrateObject::dueToMissingFields(ValidationError::class, $missingFields, stack: $this->hydrationStack);
154+
}
155+
156+
try {
157+
return new ValidationError(...$properties);
158+
} catch (Throwable $exception) {
159+
throw UnableToHydrateObject::dueToError('ApiClients\Client\GitHub\Schema\ValidationError', $exception, stack: $this->hydrationStack);
160+
}
161+
}
162+
109163
private function serializeViaTypeMap(string $accessor, object $object, array $payloadToTypeMap): array
110164
{
111165
foreach ($payloadToTypeMap as $payloadType => [$valueType, $method]) {
@@ -138,6 +192,7 @@ public function serializeObjectOfType(object $object, string $className): mixed
138192
'DateTimeImmutable' => $this->serializeValueDateTimeImmutable($object),
139193
'DateTimeInterface' => $this->serializeValueDateTimeInterface($object),
140194
'ApiClients\Client\GitHub\Schema\BasicError' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️BasicError($object),
195+
'ApiClients\Client\GitHub\Schema\ValidationError' => $this->serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️ValidationError($object),
141196
default => throw new LogicException("No serialization defined for $className"),
142197
};
143198
} catch (Throwable $exception) {
@@ -240,6 +295,35 @@ private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema
240295
return $result;
241296
}
242297

298+
private function serializeObjectApiClients⚡️Client⚡️GitHub⚡️Schema⚡️ValidationError(mixed $object): mixed
299+
{
300+
assert($object instanceof ValidationError);
301+
$result = [];
302+
303+
$message = $object->message;
304+
after_message: $result['message'] = $message;
305+
306+
$documentationUrl = $object->documentationUrl;
307+
after_documentationUrl: $result['documentation_url'] = $documentationUrl;
308+
309+
$errors = $object->errors;
310+
311+
if ($errors === null) {
312+
goto after_errors;
313+
}
314+
315+
static $errorsSerializer0;
316+
317+
if ($errorsSerializer0 === null) {
318+
$errorsSerializer0 = new SerializeArrayItems(...[]);
319+
}
320+
321+
$errors = $errorsSerializer0->serialize($errors, $this);
322+
after_errors: $result['errors'] = $errors;
323+
324+
return $result;
325+
}
326+
243327
/**
244328
* @param class-string<T> $className
245329
* @param iterable<array> $payloads;

clients/GitHub/src/Internal/Operation/Users/Follow.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ public function createResponse(ResponseInterface $response): WithoutBody
6767
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\BasicError::SCHEMA_JSON, \cebe\openapi\spec\Schema::class));
6868

6969
throw new ErrorSchemas\BasicError(401, $this->hydrator->hydrateObject(Schema\BasicError::class, $body));
70+
/**
71+
* Validation failed, or the endpoint has been spammed.
72+
**/
73+
74+
case 422:
75+
$this->responseSchemaValidator->validate($body, Reader::readFromJson(Schema\ValidationError::SCHEMA_JSON, \cebe\openapi\spec\Schema::class));
76+
77+
throw new ErrorSchemas\ValidationError(422, $this->hydrator->hydrateObject(Schema\ValidationError::class, $body));
7078
}
7179

7280
break;

clients/GitHub/src/Internal/Operator/ApiInsights/GetRouteStatsByActor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2424
{
2525
}
2626

27-
/** @return iterable<int,Schema\ApiInsightsRouteStats> */
27+
/** @return Observable<Schema\ApiInsightsRouteStats> */
2828
public function call(string $org, string $actorType, int $actorId, string $minTimestamp, string $maxTimestamp, array $sort, int $page = 1, int $perPage = 30, string $direction = 'desc'): iterable
2929
{
3030
$operation = new \ApiClients\Client\GitHub\Internal\Operation\ApiInsights\GetRouteStatsByActor($this->responseSchemaValidator, $this->hydrator, $org, $actorType, $actorId, $minTimestamp, $maxTimestamp, $sort, $page, $perPage, $direction);

clients/GitHub/src/Internal/Operator/ApiInsights/GetRouteStatsByActorListing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2424
{
2525
}
2626

27-
/** @return iterable<int,Schema\ApiInsightsRouteStats> */
27+
/** @return Observable<Schema\ApiInsightsRouteStats> */
2828
public function call(string $org, string $actorType, int $actorId, string $minTimestamp, string $maxTimestamp, array $sort, int $page = 1, int $perPage = 30, string $direction = 'desc'): iterable
2929
{
3030
$operation = new \ApiClients\Client\GitHub\Internal\Operation\ApiInsights\GetRouteStatsByActorListing($this->responseSchemaValidator, $this->hydrator, $org, $actorType, $actorId, $minTimestamp, $maxTimestamp, $sort, $page, $perPage, $direction);

clients/GitHub/src/Internal/Operator/ApiInsights/GetSubjectStats.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2424
{
2525
}
2626

27-
/** @return iterable<int,Schema\ApiInsightsSubjectStats> */
27+
/** @return Observable<Schema\ApiInsightsSubjectStats> */
2828
public function call(string $org, string $minTimestamp, string $maxTimestamp, array $sort, int $page = 1, int $perPage = 30, string $direction = 'desc'): iterable
2929
{
3030
$operation = new \ApiClients\Client\GitHub\Internal\Operation\ApiInsights\GetSubjectStats($this->responseSchemaValidator, $this->hydrator, $org, $minTimestamp, $maxTimestamp, $sort, $page, $perPage, $direction);

clients/GitHub/src/Internal/Operator/ApiInsights/GetSubjectStatsListing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2424
{
2525
}
2626

27-
/** @return iterable<int,Schema\ApiInsightsSubjectStats> */
27+
/** @return Observable<Schema\ApiInsightsSubjectStats> */
2828
public function call(string $org, string $minTimestamp, string $maxTimestamp, array $sort, int $page = 1, int $perPage = 30, string $direction = 'desc'): iterable
2929
{
3030
$operation = new \ApiClients\Client\GitHub\Internal\Operation\ApiInsights\GetSubjectStatsListing($this->responseSchemaValidator, $this->hydrator, $org, $minTimestamp, $maxTimestamp, $sort, $page, $perPage, $direction);

clients/GitHub/src/Internal/Operator/ApiInsights/GetSummaryStats.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2424
{
2525
}
2626

27+
/** @return */
2728
public function call(string $org, string $minTimestamp, string $maxTimestamp): ApiInsightsSummaryStats
2829
{
2930
$operation = new \ApiClients\Client\GitHub\Internal\Operation\ApiInsights\GetSummaryStats($this->responseSchemaValidator, $this->hydrator, $org, $minTimestamp, $maxTimestamp);

clients/GitHub/src/Internal/Operator/ApiInsights/GetSummaryStatsByActor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2424
{
2525
}
2626

27+
/** @return */
2728
public function call(string $org, string $minTimestamp, string $maxTimestamp, string $actorType, int $actorId): ApiInsightsSummaryStats
2829
{
2930
$operation = new \ApiClients\Client\GitHub\Internal\Operation\ApiInsights\GetSummaryStatsByActor($this->responseSchemaValidator, $this->hydrator, $org, $minTimestamp, $maxTimestamp, $actorType, $actorId);

clients/GitHub/src/Internal/Operator/ApiInsights/GetSummaryStatsByUser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public function __construct(private Browser $browser, private AuthenticationInte
2424
{
2525
}
2626

27+
/** @return */
2728
public function call(string $org, string $userId, string $minTimestamp, string $maxTimestamp): ApiInsightsSummaryStats
2829
{
2930
$operation = new \ApiClients\Client\GitHub\Internal\Operation\ApiInsights\GetSummaryStatsByUser($this->responseSchemaValidator, $this->hydrator, $org, $userId, $minTimestamp, $maxTimestamp);

0 commit comments

Comments
 (0)