Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const swagger = async <Path extends string = '/swagger'>(
scalarCDN = '',
scalarConfig = {},
documentation = {},
openapi = '3.0.3',
version = '5.9.0',
excludeStaticFile = true,
path = '/swagger' as Path,
Expand All @@ -37,6 +38,7 @@ export const swagger = async <Path extends string = '/swagger'>(
scalarCDN: '',
scalarConfig: {},
documentation: {},
openapi: '3.0.3',
version: '5.9.0',
excludeStaticFile: true,
path: '/swagger' as Path,
Expand Down Expand Up @@ -152,7 +154,7 @@ export const swagger = async <Path extends string = '/swagger'>(
}

return {
openapi: '3.0.3',
openapi: openapi,
...{
...documentation,
tags: documentation.tags?.filter(
Expand Down
6 changes: 6 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ export interface ElysiaSwaggerConfig<Path extends string = '/swagger'> {
* @see https://github.com/scalar/scalar/blob/main/documentation/configuration.md
*/
scalarConfig?: ReferenceConfiguration
/**
* OpenAPI version to be used
*
* @default 3.0.3
*/
openapi?: string;
/**
* Version to use for swagger cdn bundle
*
Expand Down
13 changes: 13 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ describe('Swagger', () => {
expect(res.trim().includes(expected.trim())).toBe(true)
})

it('OpenAPI version', async () => {
const app = new Elysia().use(
swagger({
openapi: '3.1.0'
})
)

await app.modules

const res = await app.handle(req('/swagger/json')).then((x) => x.json())
expect(res.openapi).toBe('3.1.0')
})

it('should not return content response when using Void type', async () => {
const app = new Elysia().use(swagger()).get('/void', () => {}, {
response: {
Expand Down