Skip to content

Commit

Permalink
optimize code
Browse files Browse the repository at this point in the history
tw2066 committed Nov 22, 2024
1 parent 8f6da17 commit 14f2726
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/Listener/AfterDtoStartListener.php
Original file line number Diff line number Diff line change
@@ -26,7 +26,8 @@ public function __construct(
private SwaggerComponents $swaggerComponents,
private SwaggerConfig $swaggerConfig,
private DtoConfig $dtoConfig,
) {}
) {
}

public function listen(): array
{
@@ -49,11 +50,13 @@ public function process(object $event): void
if (! $this->swaggerConfig->getOutputDir()) {
return;
}

$this->swaggerOpenApi->init($server['name']);

if ($this->dtoConfig->isScanCacheable()) {
return;
}

$this->swaggerOpenApi->init();
/** @var SwaggerPaths $swagger */
$swagger = make(SwaggerPaths::class, [$server['name']]);
foreach ($router->getData() ?? [] as $routeData) {
4 changes: 2 additions & 2 deletions src/Swagger/SwaggerOpenApi.php
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ public function __construct(
) {
}

public function init(): void
public function init(string $serverName): void
{
$this->openApi = new OpenApi();
$this->openApi->paths = [];
@@ -45,6 +45,7 @@ public function init(): void
$this->setComponentsSecuritySchemes();
$this->setSecurity();
$this->setExternalDocs();
$this->serverNameAll[] = $serverName;
}

public function clean(): void
@@ -139,7 +140,6 @@ public function save(string $serverName): void
}
$outputFile = $outputDir . '/' . $serverName . '.' . $this->swaggerConfig->getFormat();
$this->openApi->saveAs($outputFile);
$this->serverNameAll[] = $serverName;
}

protected function setInfo(): void

0 comments on commit 14f2726

Please sign in to comment.