From 934b3932c1c3fd54b22ff96ad1f9f8846ba9edc9 Mon Sep 17 00:00:00 2001 From: rwv <7891383+rwv@users.noreply.github.com> Date: Tue, 26 Nov 2024 07:21:30 +0800 Subject: [PATCH] feat: customize html title for swagger-ui (#845) * feat: customize html title for swagger-ui * chore: add changeset --- .changeset/swift-pigs-smile.md | 5 +++++ packages/swagger-ui/src/index.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/swift-pigs-smile.md diff --git a/.changeset/swift-pigs-smile.md b/.changeset/swift-pigs-smile.md new file mode 100644 index 00000000..a4bb9ea9 --- /dev/null +++ b/.changeset/swift-pigs-smile.md @@ -0,0 +1,5 @@ +--- +'@hono/swagger-ui': minor +--- + +customize html title for swagger-ui diff --git a/packages/swagger-ui/src/index.ts b/packages/swagger-ui/src/index.ts index d1b5a5c8..5e20f176 100644 --- a/packages/swagger-ui/src/index.ts +++ b/packages/swagger-ui/src/index.ts @@ -35,6 +35,7 @@ type OriginalSwaggerUIOptions = { * ``` */ manuallySwaggerUIHtml?: (asset: AssetURLs) => string + title?: string } type SwaggerUIOptions = OriginalSwaggerUIOptions & DistSwaggerUIOptions @@ -68,13 +69,14 @@ const SwaggerUI = (options: SwaggerUIOptions) => { const middleware = (options: SwaggerUIOptions): MiddlewareHandler => async (c) => { + const title = options?.title ?? "SwaggerUI" return c.html(/* html */ ` - SwaggerUI + ${title} ${SwaggerUI(options)}