Skip to content

Commit 3d17f25

Browse files
committed
getExampleValue can now return null
1 parent 971f87f commit 3d17f25

File tree

5 files changed

+7
-6
lines changed

5 files changed

+7
-6
lines changed

app/helpers/MetaFormats/Validators/BaseValidator.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ class BaseValidator
2121
/**
2222
* @return string Returns a sample expected value to be validated by the validator.
2323
* This value will be used in generated swagger documents.
24+
* Can return null, signalling to the swagger generator to omit the example field.
2425
*/
25-
public function getExampleValue()
26+
public function getExampleValue(): string | null
2627
{
27-
return "No example provided.";
28+
return null;
2829
}
2930

3031
/**

app/helpers/MetaFormats/Validators/VArray.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function __construct(mixed $nestedValidator = null)
2222
$this->nestedValidator = $nestedValidator;
2323
}
2424

25-
public function getExampleValue()
25+
public function getExampleValue(): string | null
2626
{
2727
if ($this->nestedValidator !== null) {
2828
return $this->nestedValidator->getExampleValue();

app/helpers/MetaFormats/Validators/VEmail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function __construct()
1313
parent::__construct(1);
1414
}
1515

16-
public function getExampleValue()
16+
public function getExampleValue(): string
1717
{
1818
return "name@domain.tld";
1919
}

app/helpers/MetaFormats/Validators/VString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(int $minLength = 0, int $maxLength = -1, ?string $re
2626
$this->regex = $regex;
2727
}
2828

29-
public function getExampleValue()
29+
public function getExampleValue(): string
3030
{
3131
return "text";
3232
}

app/helpers/MetaFormats/Validators/VUuid.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function __construct()
1212
parent::__construct(regex: "/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/");
1313
}
1414

15-
public function getExampleValue()
15+
public function getExampleValue(): string
1616
{
1717
return "10000000-2000-4000-8000-160000000000";
1818
}

0 commit comments

Comments
 (0)