Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Th3Mouk committed Jul 16, 2020
1 parent 2277bcb commit ea3a922
Showing 1 changed file with 41 additions and 23 deletions.
64 changes: 41 additions & 23 deletions Command/GenerateCommand.php
Expand Up @@ -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) {
Expand All @@ -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');

Expand Down

0 comments on commit ea3a922

Please sign in to comment.