swagger ui options

This commit is contained in:
Mohan Gupta
2023-09-14 17:51:41 +10:00
parent 47a5b26abc
commit b58f6379cf
6 changed files with 101 additions and 7 deletions

View File

@@ -65,4 +65,21 @@ describe('Swagger', () => {
const res = await app.handle(req('/v2/swagger'))
expect(res.status).toBe(200)
})
it('Swagger UI options', async () => {
const app = new Elysia().use(
swagger({
swaggerOptions: {
persistAuthorization: true
}
})
)
const res = await app.handle(req('/swagger')).then((x) => x.text())
const expected = `
window.onload = () => {
window.ui = SwaggerUIBundle({"url":"/swagger/json","dom_id":"#swagger-ui","persistAuthorization":true});
};
`
expect(res.trim().includes(expected.trim())).toBe(true)
})
})