nicordev / openapi_phpdoc_generator
Convert JSON content into OpenApi phpdoc block
0.0.1
2022-02-22 00:04 UTC
Requires
- ext-json: *
Requires (Dev)
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2025-07-09 23:21:24 UTC
README
Generate OpenApi phpdoc from json content.
Installation
Here we assume that you have php installed locally under /usr/bin
:
cp src/Shell/openapi_phpdoc_generator_command.php /usr/local/bin/openapi_phpdoc_generator # To copy the command into one of our $PATH directory
chmod +x src/Shell/openapi_phpdoc_generator_command.php /usr/local/bin # To be able to execute the script without adding php in front of the command name
Usage
In your terminal, run:
openapi_phpdoc_generator
Then you will get some explanation about how to use the command, like this:
[IS_IN_MIDDLE=1] php openapi_phpdoc_generator yourJsonFileHere [startingDepthLevelHere]
To use the OpenApiPhpdocGenerator
class in your codebase, use:
use Nicordev\OpenApiPhpdocGenerator\OpenApiPhpdocGenerator;
$ourAwesomeDecodedJsonContent = file_get_contents($ourAwesomeDecodedJsonContentFilePath);
$openApiPhpdocGenerator = new OpenApiPhpdocGenerator();
$result = $openApiPhpdocGenerator->generate($ourDecodedJsonContent, $ourStartingDepthLevel, $isInMiddleOfExistingPhpDoc);
I wish you a happy phpdoc generation!
Test
To run the test suite:
composer install
make test
If you're a docker enthusiast and you don't have php installed locally, you can do this instead:
make composer-install-using-docker
make test-using-docker
PhpStan
I've also added PHPStan, you can use it using make
commands.