luca-rath / php-json-schema
PHP classes to help create json schemas
dev-main
2020-12-12 15:53 UTC
Requires
- php: ^7.4 || ^8.0
- webmozart/assert: ^1.9
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.17
- jangregor/phpstan-prophecy: ^0.8.1
- phpspec/prophecy: ^1.12
- phpspec/prophecy-phpunit: ^2.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^0.12.59
- phpstan/phpstan-deprecation-rules: ^0.12.5
- phpstan/phpstan-phpunit: ^0.12.16
- phpstan/phpstan-strict-rules: ^0.12.5
- phpstan/phpstan-webmozart-assert: ^0.12.7
- phpunit/phpunit: ^9.5
- thecodingmachine/phpstan-strict-rules: ^0.12.1
This package is auto-updated.
Last update: 2024-04-29 04:34:07 UTC
README
PHP classes to help create json schemas
Installation
composer require luca-rath/php-json-schema
Usage
use JsonSchema\Keyword\FormatKeyword; use JsonSchema\Property\Property; use JsonSchema\Schema\IntegerSchema; use JsonSchema\Schema\ObjectSchema; use JsonSchema\Schema\StringSchema; ObjectSchema::create() ->title('Registration form') ->properties([ Property::create('email', true, StringSchema::create() ->format(FormatKeyword::FORMAT_EMAIL) ->examples(['admin@example.org'])), Property::create('password', true, StringSchema::create() ->minLength(8) ->description('The password must be at least eight characters long')), Property::create('age', false, IntegerSchema::create() ->nullable() ->minimum(18)), ]);