Skip to content

Commit de38dad

Browse files
committed
Add numeric and integer min, max example values #97
1 parent 49635dd commit de38dad

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Mpociot/ApiDoc/Generators/AbstractGenerator.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Faker\Factory;
66
use Illuminate\Foundation\Http\FormRequest;
7+
use Illuminate\Support\Arr;
78
use Illuminate\Support\Facades\Validator;
89
use Illuminate\Support\Str;
910
use Mpociot\ApiDoc\Parsers\RuleDescriptionParser as Description;
@@ -230,9 +231,15 @@ protected function parseRule($rule, $ruleName, &$attributeData, $seed)
230231
break;
231232
case 'min':
232233
$attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
234+
if (Arr::get($attributeData, 'type') === 'numeric' || Arr::get($attributeData, 'type') === 'integer') {
235+
$attributeData['value'] = $faker->numberBetween($parameters[0]);
236+
}
233237
break;
234238
case 'max':
235239
$attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
240+
if (Arr::get($attributeData, 'type') === 'numeric' || Arr::get($attributeData, 'type') === 'integer') {
241+
$attributeData['value'] = $faker->numberBetween(0, $parameters[0]);
242+
}
236243
break;
237244
case 'between':
238245
if (! isset($attributeData['type'])) {

0 commit comments

Comments
 (0)