nicordev / openapi_phpdoc_generator
Convert JSON content into OpenApi phpdoc block
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/nicordev/openapi_phpdoc_generator
Requires
- ext-json: *
Requires (Dev)
- phpstan/phpstan: ^1.4
- phpunit/phpunit: ^9.5
This package is not auto-updated.
Last update: 2026-01-08 02:15:48 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 installmake test
If you're a docker enthusiast and you don't have php installed locally, you can do this instead:
make composer-install-using-dockermake test-using-docker
PhpStan
I've also added PHPStan, you can use it using make commands.