diff --git a/src/Command/ModelCommand.php b/src/Command/ModelCommand.php index f224b6b5..b900f13c 100644 --- a/src/Command/ModelCommand.php +++ b/src/Command/ModelCommand.php @@ -10,6 +10,7 @@ use Cake\Routing\Router; use ReflectionClass; use SwaggerBake\Lib\Configuration; +use SwaggerBake\Lib\Model\ModelDecorator; use SwaggerBake\Lib\Model\ModelScanner; use SwaggerBake\Lib\Route\RouteScanner; use SwaggerBake\Lib\Utility\DataTypeConversion; @@ -32,6 +33,9 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption { $parser ->setDescription('SwaggerBake Model Checker') + ->addOption('config', [ + 'help' => 'Configuration (defaults to config/swagger_bake). Example: OtherApi.swagger_bake', + ]) ->addOption('prefix', [ 'help' => 'The route prefix (uses value in configuration by default)', ]); @@ -48,7 +52,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption */ public function execute(Arguments $args, ConsoleIo $io) { - $this->loadConfig(); + $this->loadConfig($args->getOption('config') ?? 'swagger_bake'); $io->hr(); $io->out('| SwaggerBake is checking your models...'); @@ -73,6 +77,10 @@ public function execute(Arguments $args, ConsoleIo $io) $this->abort(); } + usort($models, function (ModelDecorator $a, ModelDecorator $b) { + return strcasecmp($a->getModel()->getSchema()->name(), $b->getModel()->getSchema()->name()); + }); + $header = ['Attribute','Data Type', 'Swagger Type','Default','Primary Key']; foreach ($models as $model) { diff --git a/src/Command/RouteCommand.php b/src/Command/RouteCommand.php index 5de0b42c..c38b438a 100644 --- a/src/Command/RouteCommand.php +++ b/src/Command/RouteCommand.php @@ -29,6 +29,9 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption { $parser ->setDescription('SwaggerBake Route Checker') + ->addOption('config', [ + 'help' => 'Configuration (defaults to config/swagger_bake). Example: OtherApi.swagger_bake', + ]) ->addOption('prefix', [ 'help' => 'The route prefix (uses value in configuration by default)', ]); @@ -45,7 +48,7 @@ protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOption */ public function execute(Arguments $args, ConsoleIo $io) { - $this->loadConfig(); + $this->loadConfig($args->getOption('config') ?? 'swagger_bake'); $io->hr(); $io->out('| SwaggerBake is checking your routes...');