From 1df988377e01abfe9ef182704c6a755c34ed4c94 Mon Sep 17 00:00:00 2001 From: saltyaom Date: Sun, 7 Jan 2024 14:14:13 +0700 Subject: [PATCH] :tada: feat: merge Scalar --- example/index.ts | 8 ++++---- example/index2.ts | 2 +- package.json | 2 +- src/index.ts | 17 +++++++++++++---- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/example/index.ts b/example/index.ts index b7b531e..e97ac36 100644 --- a/example/index.ts +++ b/example/index.ts @@ -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) diff --git a/example/index2.ts b/example/index2.ts index badcd80..19e75b4 100644 --- a/example/index2.ts +++ b/example/index2.ts @@ -43,4 +43,4 @@ const app = new Elysia({ }) ) .use(plugin) - .listen(8080) + .listen(3000) diff --git a/package.json b/package.json index 4c184c3..e0d093c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.ts b/src/index.ts index 10d2ebd..cc9cb55 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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'