|
@@ -20,21 +20,20 @@ class GetFromLaravelAPI extends Strategy
|
|
|
$parameters = [];
|
|
|
|
|
|
$path = $alreadyExtractedData['uri'];
|
|
|
- preg_match_all('/\{(\w+\??)}/', $path, $matches);
|
|
|
-
|
|
|
- if (!empty($matches[1])) {
|
|
|
- foreach ($matches[1] as $match) {
|
|
|
- $optional = Str::endsWith($match, '?');
|
|
|
- $name = rtrim($match, '?');
|
|
|
- $type = 'string';
|
|
|
- $parameters[$name] = [
|
|
|
- 'name' => $name,
|
|
|
- 'description' => '',
|
|
|
- 'required' => !$optional,
|
|
|
- 'value' => $this->generateDummyValue($type),
|
|
|
- 'type' => $type,
|
|
|
- ];
|
|
|
- }
|
|
|
+ preg_match_all('#\{([^/]+?)\}#', $path, $matches);
|
|
|
+
|
|
|
+ foreach ($matches[1] as $match) {
|
|
|
+ $optional = Str::endsWith($match, '?');
|
|
|
+ $name = rtrim($match, '?');
|
|
|
+ $name = preg_replace('/:.+/', '', $name); // remove any specified regex pattern
|
|
|
+ $type = 'string';
|
|
|
+ $parameters[$name] = [
|
|
|
+ 'name' => $name,
|
|
|
+ 'description' => '',
|
|
|
+ 'required' => !$optional,
|
|
|
+ 'value' => $this->generateDummyValue($type),
|
|
|
+ 'type' => $type,
|
|
|
+ ];
|
|
|
}
|
|
|
|
|
|
return $parameters;
|