namespace BookStack\Api;
-use BookStack\Http\Controllers\Api\ApiController;
+use BookStack\Http\ApiController;
use Exception;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Collection;
class ApiDocsGenerator
{
- protected $reflectionClasses = [];
- protected $controllerClasses = [];
+ protected array $reflectionClasses = [];
+ protected array $controllerClasses = [];
/**
* Load the docs form the cache if existing
$this->controllerClasses[$className] = $class;
}
- $rules = collect($class->getValidationRules()[$methodName] ?? [])->map(function($validations) {
- return array_map(function($validation) {
+ $rules = collect($class->getValidationRules()[$methodName] ?? [])->map(function ($validations) {
+ return array_map(function ($validation) {
return $this->getValidationAsString($validation);
}, $validations);
})->toArray();
}
$class = get_class($validation);
+
throw new Exception("Cannot provide string representation of rule for class: {$class}");
}
protected function parseDescriptionFromMethodComment(string $comment): string
{
$matches = [];
- preg_match_all('/^\s*?\*\s((?![@\s]).*?)$/m', $comment, $matches);
+ preg_match_all('/^\s*?\*\s?($|((?![\/@\s]).*?))$/m', $comment, $matches);
- return implode(' ', $matches[1] ?? []);
+ $text = implode(' ', $matches[1] ?? []);
+ return str_replace(' ', "\n", $text);
}
/**