|
...
|
...
|
@@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
namespace Lackoxygen\ShowDocGeneration\Writer;
|
|
|
|
|
|
|
|
use Illuminate\Filesystem\Filesystem;
|
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
use Lackoxygen\ShowDocGeneration\Annotations\Method;
|
|
|
|
use Lackoxygen\ShowDocGeneration\Parser\Doc;
|
|
...
|
...
|
@@ -51,7 +52,7 @@ t; |
|
|
|
|
|
|
|
protected string $output = '';
|
|
|
|
|
|
|
|
public function __construct(Doc $doc)
|
|
|
|
public function __construct(Doc $doc, string $resourcePath)
|
|
|
|
{
|
|
|
|
$editTemplate = $this->template;
|
|
|
|
|
|
...
|
...
|
@@ -61,12 +62,30 @@ t; |
|
|
|
'method' => Arr::get($doc->method, 'method', Method::METHOD_GET),
|
|
|
|
'headers' => join("\n", $this->tableTbody($doc->headerLine)),
|
|
|
|
'params' => join("\n", $this->tableTbody($doc->paramLine)),
|
|
|
|
'resp' => Arr::get($doc->resp, 'value', '{}'),
|
|
|
|
'resp' => '{}',
|
|
|
|
'respRemark' => join("\n", $this->tableTbody($doc->respLine)),
|
|
|
|
'middles' => join("\n", $this->unorderedList($doc->middles)),
|
|
|
|
'updateTime' => now()->toString()
|
|
|
|
];
|
|
|
|
|
|
|
|
$respResource = Arr::get($doc->respResource, 'resource');
|
|
|
|
|
|
|
|
if ($respResource) {
|
|
|
|
$resourceInfo = pathinfo($respResource);
|
|
|
|
|
|
|
|
if (!isset($resourceInfo['extension'])) {
|
|
|
|
$respResource .= '.json';
|
|
|
|
}
|
|
|
|
|
|
|
|
$resourceFile = rtrim($resourcePath, '/\\') . DIRECTORY_SEPARATOR . $respResource;
|
|
|
|
|
|
|
|
$fs = new Filesystem();
|
|
|
|
|
|
|
|
if ($fs->exists($resourceFile) && $respData = $fs->sharedGet($resourceFile)) {
|
|
|
|
Arr::set($replaces, 'resp', $respData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->output = \str_replace(
|
|
|
|
\array_map(function (string $key) {
|
|
|
|
return '{{' . $key . '}}';
|
...
|
...
|
|