src/Command/GenerateCommand.php
public function execute(InputInterface $input, OutputInterface $output)
    {
        $options = [];

        $configFile = null;

        if (!$input->hasOption('config-file') && file_exists('.jane-openapi')) {
            $configFile = '.jane-openapi';
        } elseif($input->hasOption('config-file') && null !== $input->getOption('config-file')) {
            $configFile = $input->getOption('config-file');
        }

        if ($configFile) {
            $configFile = $input->getOption('config-file');

            if (!file_exists($configFile)) {
                throw new \RuntimeException(sprintf('Config file %s does not exist', $configFile));
            }

            $options = require $configFile;

            if (!is_array($options)) {
                throw new \RuntimeException(sprintf('Invalid config file specified or invalid return type in file %s', $configFile));
            }
        } else {
            if ($input->hasArgument('openapi-file') && null !== $input->getArgument('openapi-file')) {
                $options['openapi-file'] = $input->getArgument('openapi-file');
            }

            if ($input->hasArgument('namespace') && null !== $input->getArgument('namespace')) {
                $options['namespace'] = $input->getArgument('namespace');
            }

            if ($input->hasArgument('directory') && null !== $input->getArgument('directory')) {
                $options['directory'] = $input->getArgument('directory');
            }

            if ($input->hasOption('date-format') && null !== $input->getOption('date-format')) {
                $options['date-format'] = $input->getOption('date-format');
            }

            if ($input->hasOption('no-reference') && null !== $input->getOption('no-reference')) {
                $options['reference'] = $input->getOption('reference');
            }
        }

        $options = $this->resolveConfiguration($options);
        $registry = new Registry();

        if (array_key_exists('openapi-file', $options)) {
            $registry->addSchema($this->resolveSchema($options['openapi-file'], $options));
        } else {
            foreach ($options['mapping'] as $schema => $schemaOptions) {
                $registry->addSchema($this->resolveSchema($schema, $schemaOptions));
            }
        }

        $janeOpenApi = JaneOpenApi::build($options);
        $files       = $janeOpenApi->generate($registry);
        $janeOpenApi->printFiles($files, $registry);

        foreach ($files as $file) {
            $output->writeln(sprintf("Generate %s", $file->getFilename()));
        }
    }
public function execute(InputInterface $input, OutputInterface $output)
    {
        $options = [];

        $configFile = null;

        if (!$input->hasOption('config-file') && file_exists('.jane-openapi')) {
            $configFile = '.jane-openapi';
        } elseif($input->hasOption('config-file') && null !== $input->getOption('config-file')) {
            $configFile = $input->getOption('config-file');
        }

        if ($configFile) {
            $configFile = $input->getOption('config-file');

            if (!file_exists($configFile)) {
                throw new \RuntimeException(sprintf('Config file %s does not exist', $configFile));
            }

            $options = require $configFile;

            if (!is_array($options)) {
                throw new \RuntimeException(sprintf('Invalid config file specified or invalid return type in file %s', $configFile));
            }
        } else {
            if ($input->hasArgument('openapi-file') && null !== $input->getArgument('openapi-file')) {
                $options['openapi-file'] = $input->getArgument('openapi-file');
            }

            if ($input->hasArgument('namespace') && null !== $input->getArgument('namespace')) {
                $options['namespace'] = $input->getArgument('namespace');
            }

            if ($input->hasArgument('directory') && null !== $input->getArgument('directory')) {
                $options['directory'] = $input->getArgument('directory');
            }

            if ($input->hasOption('date-format') && null !== $input->getOption('date-format')) {
                $options['date-format'] = $input->getOption('date-format');
            }

            if ($input->hasOption('no-reference') && null !== $input->getOption('no-reference')) {
                $options['reference'] = $input->getOption('reference');
            }
        }

        $options = $this->resolveConfiguration($options);
        $registry = new Registry();

        if (array_key_exists('openapi-file', $options)) {
            $registry->addSchema($this->resolveSchema($options['openapi-file'], $options));
        } else {
            foreach ($options['mapping'] as $schema => $schemaOptions) {
                $registry->addSchema($this->resolveSchema($schema, $schemaOptions));
            }
        }

        $janeOpenApi = JaneOpenApi::build($options);
        $files       = $janeOpenApi->generate($registry);
        $janeOpenApi->printFiles($files, $registry);

        foreach ($files as $file) {
            $output->writeln(sprintf("Generate %s", $file->getFilename()));
        }
    }
{@inheritdoc}