From c88d631edab49d7f8567be1d6527668f1a7fdc7b Mon Sep 17 00:00:00 2001 From: Roman Yakoviv Date: Mon, 14 Oct 2019 14:38:15 +0300 Subject: [PATCH] Add support of constants values https://json-schema.org/understanding-json-schema/reference/generic.html#constant-values --- src/Faker.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Faker.php b/src/Faker.php index c067586..517d435 100644 --- a/src/Faker.php +++ b/src/Faker.php @@ -72,6 +72,10 @@ public function generate($schema, \stdClass $parentSchema = null, string $schema return Base::randomElement($schema->enum); } + if (isset($schema->const)) { + return Base::randomElement([$schema->const]); + } + if (! isset($this->fakers[$type])) { throw new UnsupportedTypeException($type); }