yoanm / jsonrpc-params-symfony-constraint-doc-sdk
SDK to generate JSON-RPC documentation from symfony constraint
Installs: 29 016
Dependents: 1
Suggesters: 4
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 2
Language:Gherkin
Requires
- php: ^8.0
- symfony/validator: ^4.4 || ^5.4 || ^6.0
- yoanm/jsonrpc-server-doc-sdk: ^1.0
Requires (Dev)
- behat/behat: ^3.9.0
- dvdoug/behat-code-coverage: ^5.0
- phpspec/prophecy: ^1.15
- phpspec/prophecy-phpunit: ^2.0
- phpunit/phpunit: ^9.6
- squizlabs/php_codesniffer: ^3.5
- symfony/expression-language: ^4.4 || ^5.4 || ^6.0
- symfony/intl: ^4.4 || ^5.4 || ^6.0
- yoanm/php-unit-extended: ^2.0
Suggests
- yoanm/symfony-jsonrpc-http-server: Symfony Bundle to convert an HTTP json-rpc request into HTTP json-rpc response
- yoanm/symfony-jsonrpc-http-server-doc: Symfony bundle for easy JSON-RPC server documentation
- yoanm/symfony-jsonrpc-params-sf-constraints-doc: Symfony bundle for easy Symfony constraints to JSON-RPC documentation transformation
This package is auto-updated.
Last update: 2024-10-31 00:16:47 UTC
README
PHP SDK to generate JSON-RPC documentation from symfony constraint
See yoanm/symfony-jsonrpc-params-sf-constraints-doc for automatic dependency injection.
Versions
- Symfony v3/4 PHP >=7.1 :
v0.x
- Symfony v4/5 PHP >=7.2 :
v1.0
- Symfony v4.4/5.4/6.x PHP ^8.0 :
v1.1
How to use
Create the transformer :
use Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper\ConstraintPayloadDocHelper; use Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper\DocTypeHelper; use Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper\MinMaxHelper; use Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper\StringDocHelper; use Yoanm\JsonRpcParamsSymfonyConstraintDoc\App\Helper\TypeGuesser; use Yoanm\JsonRpcParamsSymfonyConstraintDoc\Infra\Transformer\ConstraintToParamsDocTransformer; $constraintPayloadDocHelper = new ConstraintPayloadDocHelper(); $transformer = new ConstraintToParamsDocTransformer( new DocTypeHelper( $constraintPayloadDocHelper, new TypeGuesser() ), new StringDocHelper(), new MinMaxHelper(), $constraintPayloadDocHelper );
Then use it with single constraint or a list of :
use Symfony\Component\Validator\Constraints as ConstraintNS; use Yoanm\JsonRpcServerDoc\Domain\Model\Type\ObjectDoc; use Yoanm\JsonRpcServerDoc\Domain\Model\Type\StringDoc; $constraint = new ConstraintNS\Collection([ 'a' => new ConstraintNS\Type('string'), 'b' => new ConstraintNS\Type('integer'), 'c' => new ConstraintNS\Type('bool') ]); /** @var ObjectDoc $constraintDoc */ $constraintDoc = $transformer->transform($constraint); /** @var StringDoc $constraintDoc2 */ $constraintDoc2 = $transformer->transformList([ new ConstraintNS\Type('string'), new ConstraintNS\NotNull() ]);