sixlive/json-schema-assertions 问题修复 & 功能扩展

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

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

sixlive/json-schema-assertions

最新稳定版本:v2.2.0

Composer 安装命令:

composer require sixlive/json-schema-assertions

包简介

JSON Schema assertions

README 文档

README

Packagist Version Packagist Downloads StyleCI

JSON Schema schema assertions for PHP. Uses swaggest/php-json-schema under the hood.

Framework Integrations

Installation

You can install the package via composer:

> composer require --dev sixlive/json-schema-assertions

Usage

If you are making use of external schema refrences e.g. $ref: 'bar.json, you must reference the schema through file path or using the config path resolution.

├── schemas │ ├── bar.json │   └── foo.json 

You can either use the AssertsJsonSchema trait or manually construct the schema assertion.

use sixlive\JsonSchemaAssertions\Concerns\AssertJsonSchema; class ExampleTest extends TestCase { use AssertsJsonSchema; public function setUp() { parent::setUp(); $this->setJsonSchemaBasePath(__DIR__.'/../Schemas'); } /** @test */ function it_has_a_valid_response() { $this->schemaAssertion ->schema('foo') ->assert('{"foo": "bar"}'); } }
/** @test */ public function it_has_a_valid_response() { $schema = [ 'type' => 'object', 'properties' => [ 'foo' => [ 'type' => 'string', ], ], 'required' => [ 'foo', ], ]; // Schema as an array (new SchemaAssertion)->schema($schema)->assert('{"foo": "bar"}'); // Schema from raw JSON (new SchemaAssertion)->schema(json_encode($schema))->assert('{"foo": "bar"}'); // Schema from a file (new SchemaAssertion)->schema(__DIR__.'/../schemas/foo.json')) ->assert('{"foo": "bar"}'); // Remote schema (new SchemaAssertion)->schema('https://docs.foo.io/schemas/foo.json') ->assert('{"foo": "bar"}') // Schema from a path (new SchemaAssertion(__DIR__.'/../schemas/')) ->schema('foo') ->assert('{"foo": "bar"}'); }

Testing

> composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Code Style

In addition to the php-cs-fixer rules, StyleCI will apply the Laravel preset.

Linting

> composer styles:lint

Fixing

> composer styles:fix

Security

If you discover any security related issues, please email oss@tjmiller.co instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 243.47k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 2
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 3
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固