sokil / php-json-schema-defaults
Extracting default value from 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-11-09 12:34:43 UTC
README
Extracting default value from JSON Schema.
Supports drafts from v.7 or its dialects. Extractor trusts that passed schema is valid, so perform external validation for it.
Installation
composer req sokil/php-json-schema-defaults
Usage
$schema = '{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "array", "items": {"type": "string", "default": "hello"} }'; $extractor = new Extractor(); $defaultValue = $extractor->extract($schema); // ["hello"]
Console command
To get default value from schema in console use next bin:
./vendor/bin/json-schema-defaults ~/path/to/schema.json