🎉 feat: merge Scalar

This commit is contained in:
saltyaom
2024-01-07 14:14:13 +07:00
parent fe6bfc2a75
commit 1df988377e
4 changed files with 19 additions and 10 deletions

View File

@@ -9,8 +9,8 @@ const app = new Elysia({
swagger({
documentation: {
info: {
title: 'Elysia',
version: '0.7.0'
title: 'Elysia Swagger',
version: '0.8.1'
},
tags: [
{
@@ -36,8 +36,8 @@ const app = new Elysia({
},
swaggerOptions: {
persistAuthorization: true
},
}
})
)
.use(plugin)
.listen(8080)
.listen(3000)

View File

@@ -43,4 +43,4 @@ const app = new Elysia({
})
)
.use(plugin)
.listen(8080)
.listen(3000)

View File

@@ -1,6 +1,6 @@
{
"name": "@elysiajs/swagger",
"version": "0.8.0",
"version": "0.8.1",
"description": "Plugin for Elysia to auto-generate Swagger page",
"author": {
"name": "saltyAom",

View File

@@ -1,13 +1,14 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import { type Elysia, type InternalRoute } from 'elysia'
import { SwaggerUIRender } from './swagger-ui'
import { ScalarRender } from './scalar'
import { filterPaths, registerSchemaPath } from './utils'
import type { OpenAPIV3 } from 'openapi-types'
import type { ReferenceConfiguration } from '@scalar/api-reference'
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.
@@ -81,8 +82,16 @@ export const swagger =
...scalarConfig
}
return new Response(provider === 'swagger-ui' ? SwaggerUIRender(info, version, theme, stringifiedSwaggerOptions, autoDarkMode) : ScalarRender(scalarVersion, scalarConfiguration),
return new Response(
provider === 'swagger-ui'
? SwaggerUIRender(
info,
version,
theme,
stringifiedSwaggerOptions,
autoDarkMode
)
: ScalarRender(scalarVersion, scalarConfiguration),
{
headers: {
'content-type': 'text/html; charset=utf8'