diff --git a/README.md b/README.md index bd2ddff..159e694 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,12 @@ or add to the require section of your `composer.json` file. +Then add +```php +OnMoon\OpenApiServerBundle\OpenApiServerBundle::class => ['all' => true], +``` +to array in `config/bundles.php`. + ## Confirugation You can configure the bundle by adding the following parameters to your `/config/services.xml` @@ -64,7 +70,7 @@ second-api: name_prefix: 'second_' ``` -Generate the server code: `php bin/console app:openapi-generate-code` +Generate the server code: `php bin/console openapi:generate-code` Now you can implement the service interfaces generated by the previous command and put the code that should handle the api calls there. diff --git a/src/CodeGenerator/Dto/PhpParserRootDtoFactory.php b/src/CodeGenerator/Dto/PhpParserRootDtoFactory.php index dab237a..ffe3951 100644 --- a/src/CodeGenerator/Dto/PhpParserRootDtoFactory.php +++ b/src/CodeGenerator/Dto/PhpParserRootDtoFactory.php @@ -68,7 +68,7 @@ public function generateRootDto( */'); if (count($pathParameters)) { - $pathParametersDtoClassName = rtrim($className, 'Dto') . self::PATH_PARAMETERS_PREFIX; + $pathParametersDtoClassName = preg_replace('/Dto$/', '', $className) . self::PATH_PARAMETERS_PREFIX; $pathParametersDtoFileName = $pathParametersDtoClassName . '.php'; $generatedClasses[] = $this->dtoFactory->generateParamDto( diff --git a/src/CodeGenerator/ServiceInterface/PhpParserServiceInterfaceFactory.php b/src/CodeGenerator/ServiceInterface/PhpParserServiceInterfaceFactory.php index 708ef99..2044a64 100644 --- a/src/CodeGenerator/ServiceInterface/PhpParserServiceInterfaceFactory.php +++ b/src/CodeGenerator/ServiceInterface/PhpParserServiceInterfaceFactory.php @@ -49,7 +49,7 @@ public function generateServiceInterface( * This interface was automatically generated * You should not change it manually as it will be overwritten */'); - $methodBuilder = $this->factory->method($methodName); + $methodBuilder = $this->factory->method($methodName)->makePublic(); if ($summary !== null) { $methodBuilder->setDocComment(sprintf('/** %s */', $summary)); diff --git a/src/Command/GenerateApiCodeCommand.php b/src/Command/GenerateApiCodeCommand.php index 86c681f..18a975f 100644 --- a/src/Command/GenerateApiCodeCommand.php +++ b/src/Command/GenerateApiCodeCommand.php @@ -89,7 +89,7 @@ public function __construct( } /** @var string */ - protected static $defaultName = 'app:openapi-generate-code'; + protected static $defaultName = 'openapi:generate-code'; protected function execute(InputInterface $input, OutputInterface $output) : ?int {