diff --git a/src/Generator/Proxy/Schema.php b/src/Generator/Proxy/Schema.php index 0e522b9..9a2206b 100644 --- a/src/Generator/Proxy/Schema.php +++ b/src/Generator/Proxy/Schema.php @@ -50,7 +50,18 @@ public function __construct(string $type, ?string $config = null) public function generate(SpecificationInterface $specification): Generator\Code\Chunks|string { $schema = new \PSX\Schema\Schema(TypeFactory::getAny(), $specification->getDefinitions()); + $generator = $this->factory->getGenerator($this->type, $this->config); - return $this->factory->getGenerator($this->type, $this->config)->generate($schema); + $result = $generator->generate($schema); + if ($result instanceof Generator\Code\Chunks && $generator instanceof Generator\FileAwareInterface) { + $chunks = new Generator\Code\Chunks(); + foreach ($result->getChunks() as $identifier => $content) { + $chunks->append($generator->getFileName($identifier), $generator->getFileContent($content)); + } + + return $chunks; + } else { + return $result; + } } }