在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):zircote/swagger-php开源软件地址(OpenSource Url):https://github.com/zircote/swagger-php开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):swagger-phpGenerate interactive OpenAPI documentation for your RESTful API using doctrine annotations. For a full list of supported annotations, please have look at the Features
OpenAPI version support
Programmatically, the method Requirements
Composer)Installation (withcomposer require zircote/swagger-php For cli usage from anywhere install swagger-php globally and make sure to place the composer global require zircote/swagger-php UsageAdd annotations to your php files. /**
* @OA\Info(title="My First API", version="0.1")
*/
/**
* @OA\Get(
* path="/api/resource.json",
* @OA\Response(response="200", description="An example resource")
* )
*/ Visit the Documentation website for the Getting started guide or look at the Examples directory for more examples. Usage from phpGenerate always-up-to-date documentation. <?php
require("vendor/autoload.php");
$openapi = \OpenApi\Generator::scan(['/path/to/project']);
header('Content-Type: application/x-yaml');
echo $openapi->toYaml(); Documentation of how to use the Usage from the Command Line InterfaceThe ./vendor/bin/openapi --help Starting with version 4 the default analyser used on the command line is the new Using the Usage from the DeserializerGenerate the OpenApi annotation object from a json string, which makes it easier to manipulate objects programmatically. <?php
use OpenApi\Serializer;
$serializer = new Serializer();
$openapi = $serializer->deserialize($jsonString, 'OpenApi\Annotations\OpenApi');
echo $openapi->toJson(); dockerUsage fromGenerate the swagger documentation to a static json file.
More on OpenApi & Swagger
ContributingFeel free to submit Github Issues or pull requests. The documentation website is build from the docs folder with vitepress. Make sure pull requests pass PHPUnit and PHP-CS-Fixer (PSR-2) tests. To run both unit tests and linting execute:composer test Running unit tests only:./bin/phpunit Regenerate annotation/attribute reference markup docscomposer docs:refgen Running linting only:composer lint
To make |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论