Skip to content

Commit

Permalink
fix(swagger-ui): support persistAuthorization and boolean option (#265
Browse files Browse the repository at this point in the history
)

* 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>
  • Loading branch information
scarf005 and sor4chi authored Nov 20, 2023
1 parent a43558b commit 2e69707
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/soft-llamas-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/swagger-ui': minor
---

Added support for `persistAuthorization`.
2 changes: 2 additions & 0 deletions packages/swagger-ui/src/swagger/renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type DistSwaggerUIOptions = {
operationsSorter?: string
requestInterceptor?: string
responseInterceptor?: string
persistAuthorization?: boolean
}

const RENDER_TYPE = {
Expand All @@ -37,6 +38,7 @@ const RENDER_TYPE_MAP = {
operationsSorter: RENDER_TYPE.RAW,
requestInterceptor: RENDER_TYPE.RAW,
responseInterceptor: RENDER_TYPE.RAW,
persistAuthorization: RENDER_TYPE.RAW,
} as const satisfies Record<
keyof DistSwaggerUIOptions,
(typeof RENDER_TYPE)[keyof typeof RENDER_TYPE]
Expand Down
8 changes: 8 additions & 0 deletions packages/swagger-ui/test/option-renderer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,12 @@ describe('SwaggerUIOption Rendering', () => {
})
).toEqual('responseInterceptor: (res) => res')
})

it('renders correctly with persistAuthorization', () => {
expect(
renderSwaggerUIOptions({
persistAuthorization: true,
})
).toEqual('persistAuthorization: true')
})
})

0 comments on commit 2e69707

Please sign in to comment.