|
@@ -133,6 +133,7 @@ class Generator
|
|
|
})
|
|
|
->mapWithKeys(function ($tag) {
|
|
|
preg_match('/(.+?)\s+(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content);
|
|
|
+ $content = preg_replace('/\s?No-example.?/', '', $content);
|
|
|
if (empty($content)) {
|
|
|
// this means only name and type were supplied
|
|
|
list($name, $type) = preg_split('/\s+/', $tag->getContent());
|
|
@@ -150,7 +151,7 @@ class Generator
|
|
|
|
|
|
$type = $this->normalizeParameterType($type);
|
|
|
list($description, $example) = $this->parseDescription($description, $type);
|
|
|
- $value = is_null($example) ? $this->generateDummyValue($type) : $example;
|
|
|
+ $value = is_null($example) && ! $this->shouldExcludeExample($tag) ? $this->generateDummyValue($type) : $example;
|
|
|
|
|
|
return [$name => compact('type', 'description', 'required', 'value')];
|
|
|
})->toArray();
|
|
@@ -208,6 +209,7 @@ class Generator
|
|
|
})
|
|
|
->mapWithKeys(function ($tag) {
|
|
|
preg_match('/(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content);
|
|
|
+ $content = preg_replace('/\s?No-example.?/', '', $content);
|
|
|
if (empty($content)) {
|
|
|
// this means only name was supplied
|
|
|
list($name) = preg_split('/\s+/', $tag->getContent());
|
|
@@ -224,7 +226,7 @@ class Generator
|
|
|
}
|
|
|
|
|
|
list($description, $value) = $this->parseDescription($description, 'string');
|
|
|
- if (is_null($value)) {
|
|
|
+ if (is_null($value) && ! $this->shouldExcludeExample($tag)) {
|
|
|
$value = str_contains($description, ['number', 'count', 'page'])
|
|
|
? $this->generateDummyValue('integer')
|
|
|
: $this->generateDummyValue('string');
|
|
@@ -394,6 +396,19 @@ class Generator
|
|
|
return [$description, $example];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Allows users to specify that we shouldn't generate an example for the parameter
|
|
|
+ * by writing 'No-example'.
|
|
|
+ *
|
|
|
+ * @param Tag $tag
|
|
|
+ *
|
|
|
+ * @return bool Whether no example should be generated
|
|
|
+ */
|
|
|
+ private function shouldExcludeExample(Tag $tag)
|
|
|
+ {
|
|
|
+ return strpos($tag->getContent(), ' No-example') !== false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Cast a value from a string to a specified type.
|
|
|
*
|