sokil / php-json-schema-defaults
从 JSON Schema 提取默认值
0.1.0
2023-04-09 09:16 UTC
Requires
- php: ^8.1
Requires (Dev)
- opis/json-schema: ^2.3
- php-coveralls/php-coveralls: ^2.5
- phpunit/phpunit: ^9.5.21
- squizlabs/php_codesniffer: ^3.7
- vimeo/psalm: ^4.24
This package is auto-updated.
Last update: 2024-09-09 12:11:32 UTC
README
从 JSON Schema 提取默认值。
支持 v.7 或其方言的草案。提取器假定传入的 schema 是有效的,因此请对其进行外部验证。
安装
composer req sokil/php-json-schema-defaults
用法
$schema = '{ "$schema": "https://json-schema.fullstack.org.cn/draft-07/schema#", "type": "array", "items": {"type": "string", "default": "hello"} }'; $extractor = new Extractor(); $defaultValue = $extractor->extract($schema); // ["hello"]
控制台命令
要在控制台从 schema 获取默认值,请使用以下 bin
./vendor/bin/json-schema-defaults ~/path/to/schema.json