sonrac/swagger-php-openapi 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sonrac/swagger-php-openapi

Composer 安装命令:

composer require sonrac/swagger-php-openapi

包简介

Swagger-PHP - Generate interactive documentation for your RESTful API using phpdoc annotations

README 文档

README

Build Status Total Downloads License

swagger-php

Generate interactive OpenAPI documentation for your RESTful API using doctrine annotations.

Features

  • Compatible with the OpenAPI 3.0 specification.
  • Exceptional error reporting (with hints, context)
  • Extracts information from code & existing phpdoc annotations.
  • Command-line interface available.

Installation (with Composer)

composer require sonrac/swagger-php-openapi

For cli usage from anywhere install swagger-php globally and make sure to place the ~/.composer/vendor/bin directory in your PATH so the swagger executable can be located by your system.

composer global require sonrac/swagger-php-openapi

Usage

Add annotations to your php files.

/**
 * @OAS\Info(title="My First API", version="0.1")
 */

/**
 * @OAS\Get(
 *     path="/api/resource.json",
 *     @OAS\Response(response="200", description="An example resource")
 * )
 */

See the Getting started guide and Examples directory for more examples.

Usage from php

Generate always-up-to-date documentation.

<?php
require("vendor/autoload.php");
$openapi = \Swagger\scan('/path/to/project');
header('Content-Type: application/json');
echo $openapi;

Usage from the Command Line Interface

Generate the swagger documentation to a static json file.

./vendor/bin/swagger --help

Usage from the Deserializer

Generate the OpenApi annotation object from a json string, which makes it easier to manipulate objects programmatically.

<?php

use Swagger\Serializer;

$serializer = new Serializer();
$openapi = $serializer->deserialize($jsonString, 'Swagger\Annotations\OpenApi');
echo $openapi;

More on OpenAPI

Contributing

Feel free to submit Github Issues or pull requests.

The documentation website resides within the gh-pages branch.

Make sure pull requests pass PHPUnit and PHP_CodeSniffer (PSR-2) tests.

Running tests can be done with this command in the root of the project:

./bin/phpunit

To run the phpcs tests on your local machine execute:

./bin/phpcs -p --extensions=php --standard=PSR2 --error-severity=1 --warning-severity=0 ./src ./tests

To run both unittests and linting execute:

composer test

Bitdeli Badge

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-06-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固