定制 sixlive/laravel-json-schema-assertions 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

sixlive/laravel-json-schema-assertions

最新稳定版本:v4.4.0

Composer 安装命令:

composer require sixlive/laravel-json-schema-assertions

包简介

Laravel JSON Schema assertions

README 文档

README

Packagist Version Packagist Downloads StyleCI

JSON Schema schema assertions for Laravel test responses. Uses swaggest/php-json-schema under the hood.

Installation

You can install the package via composer:

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

This package uses Laravel's package discovery to register the service provider to the framework. If you are using an older version of Laravel or do not use package discovery see below.

Provider registration
// config/app.php 'providers' => [ sixlive\Laravel\JsonSchemaAssertions\ServiceProvider::class, ]

Configuration

Publish the packages config file:

> php artisan vendor:publish --provider="sixlive\Laravel\JsonSchemaAssertions\ServiceProvider" --tag="config"

This is the contents of the file which will be published at config/json-schema-assertions:

return [ 'schema_base_path' => base_path('schemas'), ];

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.

├── app ├── bootstrap ├── config ├── database ├── public ├── resources ├── routes ├── schemas │ ├── bar.json │   └── foo.json ├── storage ├── tests └── vendor 
/** @test */ public function it_has_a_valid_response() { $schema = [ 'type' => 'object', 'properties' => [ 'foo' => [ 'type' => 'string', ], ], 'required' => [ 'foo', ], ]; $response = $this->get('/foo'); // Schema as an array $response->assertJsonSchema($schema); // Schema from raw JSON $response->assertJsonSchema(json_encode($schema)); // Schema from a file $response->assertJsonSchema(base_path('schemas/foo.json')); // Schema from config path $response->assertJsonSchema('foo'); // Remote schema $response->assertJsonSchema('https://docs.foo.io/schemas/foo.json'); }

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.

统计信息

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

GitHub 信息

  • Stars: 70
  • Watchers: 2
  • Forks: 13
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固