fix(swagger-ui): support `persistAuthorization` and boolean option (#265)

* feat: `persistAuthorization`

Co-authored-by: Sor4chi <80559385+sor4chi@users.noreply.github.com>

* test: `persistAuthorization`

* chore: changeset

Co-authored-by: Sor4chi <80559385+sor4chi@users.noreply.github.com>

---------

Co-authored-by: Sor4chi <80559385+sor4chi@users.noreply.github.com>
pull/266/head
scarf 2023-11-20 14:08:12 +09:00 committed by GitHub
parent a43558b2d6
commit 2e697077bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
'@hono/swagger-ui': minor
---
Added support for `persistAuthorization`.

View File

@ -14,6 +14,7 @@ export type DistSwaggerUIOptions = {
operationsSorter?: string operationsSorter?: string
requestInterceptor?: string requestInterceptor?: string
responseInterceptor?: string responseInterceptor?: string
persistAuthorization?: boolean
} }
const RENDER_TYPE = { const RENDER_TYPE = {
@ -37,6 +38,7 @@ const RENDER_TYPE_MAP = {
operationsSorter: RENDER_TYPE.RAW, operationsSorter: RENDER_TYPE.RAW,
requestInterceptor: RENDER_TYPE.RAW, requestInterceptor: RENDER_TYPE.RAW,
responseInterceptor: RENDER_TYPE.RAW, responseInterceptor: RENDER_TYPE.RAW,
persistAuthorization: RENDER_TYPE.RAW,
} as const satisfies Record< } as const satisfies Record<
keyof DistSwaggerUIOptions, keyof DistSwaggerUIOptions,
(typeof RENDER_TYPE)[keyof typeof RENDER_TYPE] (typeof RENDER_TYPE)[keyof typeof RENDER_TYPE]

View File

@ -124,4 +124,12 @@ describe('SwaggerUIOption Rendering', () => {
}) })
).toEqual('responseInterceptor: (res) => res') ).toEqual('responseInterceptor: (res) => res')
}) })
it('renders correctly with persistAuthorization', () => {
expect(
renderSwaggerUIOptions({
persistAuthorization: true,
})
).toEqual('persistAuthorization: true')
})
}) })