nicordev / openapi_phpdoc_generator
将 JSON 内容转换为 OpenApi phpdoc 块
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: 2024-10-02 19:05:42 UTC
README
从 JSON 内容生成 OpenApi phpdoc。
安装
这里我们假设您已经在 /usr/bin
下本地安装了 php
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
用法
在您的终端中,运行
openapi_phpdoc_generator
然后您将得到一些关于如何使用命令的解释,例如这样
[IS_IN_MIDDLE=1] php openapi_phpdoc_generator yourJsonFileHere [startingDepthLevelHere]
要在您的代码库中使用 OpenApiPhpdocGenerator
类,使用
use Nicordev\OpenApiPhpdocGenerator\OpenApiPhpdocGenerator;
$ourAwesomeDecodedJsonContent = file_get_contents($ourAwesomeDecodedJsonContentFilePath);
$openApiPhpdocGenerator = new OpenApiPhpdocGenerator();
$result = $openApiPhpdocGenerator->generate($ourDecodedJsonContent, $ourStartingDepthLevel, $isInMiddleOfExistingPhpDoc);
祝您快乐地生成 phpdoc!
测试
要运行测试套件
composer install
make test
如果您是 Docker 爱好者并且没有在本地安装 php,您可以这样做
make composer-install-using-docker
make test-using-docker
PhpStan
我还添加了 PHPStan,您可以使用 make
命令来使用它。