Generate an ast node (which correspond to a class) for a OpenApi spec
public generate ( Joli\Jane\OpenApi\Model\OpenApi $openApi, string $namespace, Joli\Jane\Generator\Context\Context $context, string $suffix = 'Resource' ) : PhpParser\Node[] | ||
$openApi | Joli\Jane\OpenApi\Model\OpenApi | |
$namespace | string | |
$context | Joli\Jane\Generator\Context\Context | |
$suffix | string | |
return | PhpParser\Node[] |
/** * Generate a list of files * * @param string $openApiSpec Location of the specification * @param string $namespace Namespace of the library * @param string $directory Path for the root directory of the generated files * * @return File[] */ public function generate($openApiSpec, $namespace, $directory) { /** @var OpenApi $openApi */ $context = $this->createContext($openApiSpec, 'Client', $namespace, $directory); $files = []; $files = array_merge($files, $this->modelGenerator->generate($context->getRootReference(), 'Client', $context)); $files = array_merge($files, $this->normalizerGenerator->generate($context->getRootReference(), 'Client', $context)); $clients = $this->clientGenerator->generate($context->getRootReference(), $namespace, $context); foreach ($clients as $node) { $files[] = new File($directory . DIRECTORY_SEPARATOR . 'Resource' . DIRECTORY_SEPARATOR . $node->stmts[2]->name . '.php', $node, ''); } return $files; }