Add jane-php/json-schema recipe

This commit is contained in:
Baptiste Leduc
2020-02-11 16:42:35 +01:00
parent 0153a82a84
commit 7fca26ec1a
5 changed files with 64 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env php
<?php
require __DIR__ . '/../vendor/autoload.php';
use Jane\JsonSchema\Command\GenerateCommand;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
$command = new GenerateCommand();
$inputArray = new ArrayInput(['--config-file' => __DIR__ . '/../config/jane/config.php'], $command->getDefinition());
$command->execute($inputArray, new NullOutput());
@@ -0,0 +1,8 @@
<?php
return [
'json-schema-file' => __DIR__ . '/json-schema.json',
'root-class' => 'MyModel',
'namespace' => 'MyApp\Library\Generated',
'directory' => __DIR__ . '/../../generated',
];
@@ -0,0 +1,25 @@
services:
jane.serializer.json_encode:
class: Symfony\Component\Serializer\Encoder\JsonEncode
arguments:
- { json_encode_options: 64 } # \JSON_UNESCAPED_SLASHES
jane.serializer.json_decode:
class: Symfony\Component\Serializer\Encoder\JsonDecode
arguments:
- { json_decode_associative: false }
jane.serializer.json_encoder:
class: Symfony\Component\Serializer\Encoder\JsonEncoder
arguments:
- '@jane.serializer.json_encode'
- '@jane.serializer.json_decode'
# jane.serializer.object:
# class: MyApp\Library\Generated\Normalizer\JaneObjectNormalizer
#
# jane.serializer:
# class: Symfony\Component\Serializer\Serializer
# arguments:
# - ['@serializer.denormalizer.array', '@jane.serializer.object']
# - ['@jane.serializer.json_encoder']
+6
View File
@@ -0,0 +1,6 @@
{
"copy-from-recipe": {
"bin/": "%BIN_DIR%/",
"config/": "%CONFIG_DIR%/"
}
}
+12
View File
@@ -0,0 +1,12 @@
<bg=blue;fg=white> </>
<bg=blue;fg=white> JanePHP - JSON Schema </>
<bg=blue;fg=white> </>
* <fg=blue>Finish</> package configuration:
1. Configure <comment>config/jane/config.php</> with your specification details
2. Run <comment>bin/jane-generate</>
3. Add <comment>generated/</> directory to your composer autoload definition (eg. <comment>"MyApp\\Library\\Generated\\": "generated/"</>)
4. Open <comment>config/packages/jane.yaml</> and replace <comment>MyApp\Library\Generated\Normalizer\JaneObjectNormalizer</> class with your generated normalizer.
5. Then remove line comments
Documentation: https://jane.readthedocs.io/en/latest/