Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/Gatherer/WebHookHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public static function gather(

$schemaClasses = [];
foreach ($webHooks as $webHook) {
foreach ($webHook->schema as $schema) {
$schemaClasses[] = $schema;
foreach ($webHook->schema as $webHookSchema) {
foreach (self::listSchemas($webHookSchema) as $schema) {
$schemaClasses[] = $schema;
}
}
}

Expand All @@ -31,4 +33,19 @@ public static function gather(
...$schemaClasses,
);
}

/**
* @return iterable<\ApiClients\Tools\OpenApiClientGenerator\Representation\Schema>
*/
private static function listSchemas(\ApiClients\Tools\OpenApiClientGenerator\Representation\Schema $schema): iterable
{
foreach ($schema->properties as $property) {
foreach ($property->type as $propertyType) {
if ($propertyType->payload instanceof \ApiClients\Tools\OpenApiClientGenerator\Representation\Schema) {
yield $propertyType->payload;
yield from self::listSchemas($propertyType->payload);
}
}
}
}
}
8 changes: 4 additions & 4 deletions src/Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,28 @@ public function generate(string $namespace, string $destinationPath)
new Node\Stmt\Use_([
new Node\Stmt\UseUse(
new Node\Name(
$namespace . 'Hydrator',
ltrim($namespace, '\\') . 'Hydrator',
)
)
]),
new Node\Stmt\Use_([
new Node\Stmt\UseUse(
new Node\Name(
$namespace . 'Operation',
ltrim($namespace, '\\') . 'Operation',
)
)
]),
new Node\Stmt\Use_([
new Node\Stmt\UseUse(
new Node\Name(
$namespace . 'Schema',
ltrim($namespace, '\\') . 'Schema',
)
)
]),
new Node\Stmt\Use_([
new Node\Stmt\UseUse(
new Node\Name(
$namespace . 'WebHook',
ltrim($namespace, '\\') . 'WebHook',
)
)
]),
Expand Down