mlambley/swagvalidator
Composer 安装命令:
composer require mlambley/swagvalidator
包简介
Validates data against a Swagger schema
README 文档
README
Validates data against a Swagger schema
How to Install
composer require --dev mlambley/swagvalidator
What is Swagger?
Swagger 2.0 (aka Open API 2.0) defines the structure of your API, including end points and the structure of input and output data. See their website for more information.
What is Swagvalidator?
If you have an existing Swagger 2.0 specification, you can use it to validate data coming in or out of your API using this tool. This library fully takes into account the features of the Swagger 2.0 specification.
Requirements
None. This is a pure PHP tool with no dependencies and will work with PHP 5.6 onwards.
Usage
use Mlambley\Swagvalidator\Validator\Validator; use Mlambley\Swagvalidator\Exception\ValidationException; $response = $this->getApi("your/path"); $json = (string)$response->getBody(); $data = json_decode($json); $schema = json_decode(file_get_contents(__DIR__ . '/swagger.json')); try { (new Validator()) ->validate($schema->paths->{"your/path"}->get->responses->{"200"}->schema, $data); } catch (ValidationException $e) { //dd($e->getMessage()); }
Issues?
Log a github issue. Your assistance is appreciated.
统计信息
- 总下载量: 68
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-02