mirror of
https://github.com/zoriya/elysia-swagger.git
synced 2025-12-06 00:36:10 +00:00
🎉 feat: merge Scalar
This commit is contained in:
@@ -9,8 +9,8 @@ const app = new Elysia({
|
|||||||
swagger({
|
swagger({
|
||||||
documentation: {
|
documentation: {
|
||||||
info: {
|
info: {
|
||||||
title: 'Elysia',
|
title: 'Elysia Swagger',
|
||||||
version: '0.7.0'
|
version: '0.8.1'
|
||||||
},
|
},
|
||||||
tags: [
|
tags: [
|
||||||
{
|
{
|
||||||
@@ -36,8 +36,8 @@ const app = new Elysia({
|
|||||||
},
|
},
|
||||||
swaggerOptions: {
|
swaggerOptions: {
|
||||||
persistAuthorization: true
|
persistAuthorization: true
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.use(plugin)
|
.use(plugin)
|
||||||
.listen(8080)
|
.listen(3000)
|
||||||
|
|||||||
@@ -43,4 +43,4 @@ const app = new Elysia({
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
.use(plugin)
|
.use(plugin)
|
||||||
.listen(8080)
|
.listen(3000)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@elysiajs/swagger",
|
"name": "@elysiajs/swagger",
|
||||||
"version": "0.8.0",
|
"version": "0.8.1",
|
||||||
"description": "Plugin for Elysia to auto-generate Swagger page",
|
"description": "Plugin for Elysia to auto-generate Swagger page",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "saltyAom",
|
"name": "saltyAom",
|
||||||
|
|||||||
17
src/index.ts
17
src/index.ts
@@ -1,13 +1,14 @@
|
|||||||
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
||||||
import { type Elysia, type InternalRoute } from 'elysia'
|
import { type Elysia, type InternalRoute } from 'elysia'
|
||||||
|
|
||||||
|
import { SwaggerUIRender } from './swagger-ui'
|
||||||
|
import { ScalarRender } from './scalar'
|
||||||
|
|
||||||
import { filterPaths, registerSchemaPath } from './utils'
|
import { filterPaths, registerSchemaPath } from './utils'
|
||||||
|
|
||||||
import type { OpenAPIV3 } from 'openapi-types'
|
import type { OpenAPIV3 } from 'openapi-types'
|
||||||
import type { ReferenceConfiguration } from '@scalar/api-reference'
|
import type { ReferenceConfiguration } from '@scalar/api-reference'
|
||||||
import type { ElysiaSwaggerConfig } from './types'
|
import type { ElysiaSwaggerConfig } from './types'
|
||||||
import { SwaggerUIRender } from './swagger-ui'
|
|
||||||
import { ScalarRender } from './scalar'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin for [elysia](https://github.com/elysiajs/elysia) that auto-generate Swagger page.
|
* Plugin for [elysia](https://github.com/elysiajs/elysia) that auto-generate Swagger page.
|
||||||
@@ -81,8 +82,16 @@ export const swagger =
|
|||||||
...scalarConfig
|
...scalarConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return new Response(
|
||||||
return new Response(provider === 'swagger-ui' ? SwaggerUIRender(info, version, theme, stringifiedSwaggerOptions, autoDarkMode) : ScalarRender(scalarVersion, scalarConfiguration),
|
provider === 'swagger-ui'
|
||||||
|
? SwaggerUIRender(
|
||||||
|
info,
|
||||||
|
version,
|
||||||
|
theme,
|
||||||
|
stringifiedSwaggerOptions,
|
||||||
|
autoDarkMode
|
||||||
|
)
|
||||||
|
: ScalarRender(scalarVersion, scalarConfiguration),
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'content-type': 'text/html; charset=utf8'
|
'content-type': 'text/html; charset=utf8'
|
||||||
|
|||||||
Reference in New Issue
Block a user