Skip to content

Commit cef8377

Browse files
committed
v3
1 parent c409f31 commit cef8377

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

resources/definitions/openapi.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
'router.swagger.css_urls' => SwaggerConfiguration::DEFAULT_CSS_URLS,
4343
'router.swagger.js_urls' => SwaggerConfiguration::DEFAULT_JS_URLS,
4444
'router.swagger.openapi_uri' => SwaggerConfiguration::DEFAULT_OPENAPI_URI,
45+
'router.swagger.template_variables' => [],
4546

4647
OpenApiConfiguration::class => create()
4748
->constructor(
@@ -82,5 +83,6 @@
8283
cssUrls: get('router.swagger.css_urls'),
8384
jsUrls: get('router.swagger.js_urls'),
8485
openapiUri: get('router.swagger.openapi_uri'),
86+
templateVariables: get('router.swagger.template_variables'),
8587
),
8688
];

src/OpenApi/Controller/SwaggerController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
5656
TemplateRenderer::renderTemplate(
5757
filename: $this->swaggerConfiguration->templateFilename,
5858
variables: [
59+
...$this->swaggerConfiguration->templateVariables,
5960
self::CSS_URLS_VAR_NAME => $this->swaggerConfiguration->cssUrls,
6061
self::JS_URLS_VAR_NAME => $this->swaggerConfiguration->jsUrls,
6162
self::OPENAPI_URI_VAR_NAME => $this->swaggerConfiguration->openapiUri,

src/OpenApi/SwaggerConfiguration.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ final class SwaggerConfiguration
3535

3636
public function __construct(
3737
public readonly string $templateFilename = self::DEFAULT_TEMPLATE_FILENAME,
38-
/** @var string[] */
38+
/** @var array<array-key, string> */
3939
public readonly array $cssUrls = self::DEFAULT_CSS_URLS,
40-
/** @var string[] */
40+
/** @var array<array-key, string> */
4141
public readonly array $jsUrls = self::DEFAULT_JS_URLS,
4242
public readonly string $openapiUri = self::DEFAULT_OPENAPI_URI,
43+
/** @var array<string, mixed> */
44+
public readonly array $templateVariables = [],
4345
) {
4446
}
4547
}

0 commit comments

Comments
 (0)