From 6612311bb8c9a1fee94dfaeaf57586671b01ca75 Mon Sep 17 00:00:00 2001 From: Adrien Brault Date: Mon, 22 Apr 2024 23:16:06 +0200 Subject: [PATCH] docs: oooas --- README.md | 3 +++ composer.json | 1 + demo/oooas.php | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 demo/oooas.php diff --git a/README.md b/README.md index 20d9b1f..aec28ed 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,9 @@ $label = $instructrice->get( assert($label === 'positive'); ``` +You can also use third party json schema libraries like [goldspecdigital/oooas][oooas] to generate the schema: +- [demo/oooas.php](demo/oooas.php) + https://github.com/adrienbrault/instructrice/assets/611271/da69281d-ac56-4135-b2ef-c5e306a56de2 ## Supported providers diff --git a/composer.json b/composer.json index fa60aad..1e43bd2 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ }, "require-dev": { "ergebnis/composer-normalize": "^2.42", + "goldspecdigital/oooas": "^2.10", "monolog/monolog": "^3.0", "php-standard-library/phpstan-extension": "^1.0", "phpstan/phpstan": "^1.10", diff --git a/demo/oooas.php b/demo/oooas.php new file mode 100644 index 0000000..eaeee77 --- /dev/null +++ b/demo/oooas.php @@ -0,0 +1,37 @@ +get( + Schema::object() + ->properties( + Schema::string('name'), + Schema::string('dateOfBirth')->format(Schema::FORMAT_DATE_TIME), + Schema::boolean('isAlive'), + Schema::array('significantContributions') + ->items(Schema::string()), + ) + ->toArray(), + 'Most impact scientists in history.', + onChunk: InstructriceFactory::createOnChunkDump($output->section()), + ); +}); + +/* +1 array:4 [ + "name" => "Marie Curie" + "dateOfBirth" => "1867-11-07" + "isAlive" => false + "significantContributions" => array:3 [ + 0 => "Pioneered radioactivity research" + 1 => "First woman to win a Nobel Prize" + 2 => "First person to win two Nobel Prizes in different fields (Physics and Chemistry)" + ] +] +*/