From ea3a9225e3ba711753e4db24ae16d061b4353c5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Je=CC=81re=CC=81my=20Marodon?= Date: Thu, 16 Jul 2020 17:44:33 +0200 Subject: [PATCH] fixup --- Command/GenerateCommand.php | 64 ++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/Command/GenerateCommand.php b/Command/GenerateCommand.php index b563f99..afb5649 100644 --- a/Command/GenerateCommand.php +++ b/Command/GenerateCommand.php @@ -47,9 +47,18 @@ private function generateJson(InputInterface $input): void $template = $this->getFirstElementOfFileIterator($template_file); - $template = Yaml::parse($template->getContents()); - $components = $template['components'] ?? []; - $paths = $template['paths'] ?? []; + $template = Yaml::parse($template->getContents()); + $components = $template['components'] ?? []; + $schemas = []; + $responses = []; + $parameters = []; + $examples = []; + $request_bodies = []; + $headers = []; + $security_schemes = []; + $links = []; + $callbacks = []; + $paths = $template['paths'] ?? []; foreach ($this->getContentGenerator(PathHelper::PATHS) as $path) { if (null === $path) { @@ -59,44 +68,53 @@ private function generateJson(InputInterface $input): void $paths[key($path)] = $path[key($path)]; } - foreach ($this->getContentGenerator(PathHelper::SCHEMAS) as $definition) { - $components['schemas'] = $definition; + foreach ($this->getContentGenerator(PathHelper::SCHEMAS) as $schema) { + $schemas[] = $schema; } - foreach ($this->getContentGenerator(PathHelper::RESPONSES) as $definition) { - $components['responses'] = $definition; + foreach ($this->getContentGenerator(PathHelper::RESPONSES) as $response) { + $responses[] = $response; } - foreach ($this->getContentGenerator(PathHelper::PARAMETERS) as $definition) { - $components['parameters'] = $definition; + foreach ($this->getContentGenerator(PathHelper::PARAMETERS) as $parameter) { + $parameters[] = $parameter; } - foreach ($this->getContentGenerator(PathHelper::EXAMPLES) as $definition) { - $components['examples'] = $definition; + foreach ($this->getContentGenerator(PathHelper::EXAMPLES) as $example) { + $examples[] = $example; } - foreach ($this->getContentGenerator(PathHelper::REQUEST_BODIES) as $definition) { - $components['requestBodies'] = $definition; + foreach ($this->getContentGenerator(PathHelper::REQUEST_BODIES) as $request_body) { + $request_bodies[] = $request_body; } - foreach ($this->getContentGenerator(PathHelper::HEADERS) as $definition) { - $components['headers'] = $definition; + foreach ($this->getContentGenerator(PathHelper::HEADERS) as $header) { + $headers[] = $header; } - foreach ($this->getContentGenerator(PathHelper::SECURITY_SCHEMES) as $definition) { - $components['securitySchemes'] = $definition; + foreach ($this->getContentGenerator(PathHelper::SECURITY_SCHEMES) as $security_scheme) { + $security_schemes[] = $security_scheme; } - foreach ($this->getContentGenerator(PathHelper::LINKS) as $definition) { - $components['links'] = $definition; + foreach ($this->getContentGenerator(PathHelper::LINKS) as $link) { + $links[] = $link; } - foreach ($this->getContentGenerator(PathHelper::CALLBACKS) as $definition) { - $components['callbacks'] = $definition; + foreach ($this->getContentGenerator(PathHelper::CALLBACKS) as $callback) { + $callbacks[] = $callback; } - $template['components'] = (object) $components; - $template['paths'] = (object) $paths; + $components['schemas'] = (object) $schemas; + $components['responses'] = (object) $responses; + $components['parameters'] = (object) $parameters; + $components['examples'] = (object) $examples; + $components['requestBodies'] = (object) $request_bodies; + $components['headers'] = (object) $headers; + $components['securitySchemes'] = (object) $security_schemes; + $components['links'] = (object) $links; + $components['callbacks'] = (object) $callbacks; + $template['components'] = (object) $components; + $template['paths'] = (object) $paths; $arg_path = $input->getArgument('path');