Skip to content

Commit 5b44522

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents df97ad4 + 2c55075 commit 5b44522

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Listener/BootAppRouteListener.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public function process(object $event): void
7878
$route->get('/scalar', [SwaggerUiController::class, 'scalar']);
7979
$route->get('/doc', [SwaggerUiController::class, 'knife4j']);
8080
$route->get('/swagger-resources', [SwaggerUiController::class, 'swaggerResources']);
81+
$route->get('/v3/api-docs/swagger-config', [SwaggerUiController::class, 'swaggerConfig']);
8182
$route->get('/webjars/{file:.*}', [SwaggerUiController::class, 'knife4jFile']);
8283
$route->get('/favicon.ico', [SwaggerUiController::class, 'favicon']);
8384

src/Swagger/SwaggerUiController.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public function rapidoc(): PsrResponseInterface
4747
$contents = str_replace('{{$url}}', BootAppRouteListener::$httpServerName . '.' . $this->swaggerConfig->getFormat(), $contents);
4848
return $this->response->withAddedHeader('content-type', 'text/html')->withBody(new SwooleStream($contents));
4949
}
50+
5051
public function scalar(): PsrResponseInterface
5152
{
5253
// https://github.com/scalar/scalar
@@ -77,6 +78,16 @@ public function swaggerResources()
7778
return $urls;
7879
}
7980

81+
/**
82+
* 适配knife4j 4.5.0版本.
83+
*/
84+
public function swaggerConfig(): array
85+
{
86+
$urls = $this->swaggerResources();
87+
$data['urls'] = $urls;
88+
return $data;
89+
}
90+
8091
public function knife4jFile(string $file): PsrResponseInterface
8192
{
8293
$file = str_replace('..', '', $file);

0 commit comments

Comments
 (0)