From 7fca26ec1a3498ec88e1963e6db3d78d7dfe0841 Mon Sep 17 00:00:00 2001 From: Baptiste Leduc Date: Fri, 7 Feb 2020 11:40:18 +0100 Subject: [PATCH] Add jane-php/json-schema recipe --- jane-php/json-schema/5.0/bin/jane-generate | 13 ++++++++++ .../json-schema/5.0/config/jane/config.php | 8 ++++++ .../json-schema/5.0/config/packages/jane.yaml | 25 +++++++++++++++++++ jane-php/json-schema/5.0/manifest.json | 6 +++++ jane-php/json-schema/5.0/post-install.txt | 12 +++++++++ 5 files changed, 64 insertions(+) create mode 100755 jane-php/json-schema/5.0/bin/jane-generate create mode 100644 jane-php/json-schema/5.0/config/jane/config.php create mode 100644 jane-php/json-schema/5.0/config/packages/jane.yaml create mode 100644 jane-php/json-schema/5.0/manifest.json create mode 100644 jane-php/json-schema/5.0/post-install.txt diff --git a/jane-php/json-schema/5.0/bin/jane-generate b/jane-php/json-schema/5.0/bin/jane-generate new file mode 100755 index 00000000..0b13fca6 --- /dev/null +++ b/jane-php/json-schema/5.0/bin/jane-generate @@ -0,0 +1,13 @@ +#!/usr/bin/env php + __DIR__ . '/../config/jane/config.php'], $command->getDefinition()); + +$command->execute($inputArray, new NullOutput()); diff --git a/jane-php/json-schema/5.0/config/jane/config.php b/jane-php/json-schema/5.0/config/jane/config.php new file mode 100644 index 00000000..83506b6c --- /dev/null +++ b/jane-php/json-schema/5.0/config/jane/config.php @@ -0,0 +1,8 @@ + __DIR__ . '/json-schema.json', + 'root-class' => 'MyModel', + 'namespace' => 'MyApp\Library\Generated', + 'directory' => __DIR__ . '/../../generated', +]; diff --git a/jane-php/json-schema/5.0/config/packages/jane.yaml b/jane-php/json-schema/5.0/config/packages/jane.yaml new file mode 100644 index 00000000..59ff9b33 --- /dev/null +++ b/jane-php/json-schema/5.0/config/packages/jane.yaml @@ -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'] diff --git a/jane-php/json-schema/5.0/manifest.json b/jane-php/json-schema/5.0/manifest.json new file mode 100644 index 00000000..e2920638 --- /dev/null +++ b/jane-php/json-schema/5.0/manifest.json @@ -0,0 +1,6 @@ +{ + "copy-from-recipe": { + "bin/": "%BIN_DIR%/", + "config/": "%CONFIG_DIR%/" + } +} diff --git a/jane-php/json-schema/5.0/post-install.txt b/jane-php/json-schema/5.0/post-install.txt new file mode 100644 index 00000000..524d8f78 --- /dev/null +++ b/jane-php/json-schema/5.0/post-install.txt @@ -0,0 +1,12 @@ + + JanePHP - JSON Schema + + + * Finish package configuration: + 1. Configure config/jane/config.php with your specification details + 2. Run bin/jane-generate + 3. Add generated/ directory to your composer autoload definition (eg. "MyApp\\Library\\Generated\\": "generated/") + 4. Open config/packages/jane.yaml and replace MyApp\Library\Generated\Normalizer\JaneObjectNormalizer class with your generated normalizer. + 5. Then remove line comments + +Documentation: https://jane.readthedocs.io/en/latest/