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
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-08-28 19:02:11 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