From 7b1d18361199523fa40d493fe95efcbec29261d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aykut=20Akg=C3=BCn?= <68244453+Autumnlight02@users.noreply.github.com> Date: Tue, 9 Apr 2024 11:07:14 +0200 Subject: [PATCH] bugfix(accept external swagger paths) --- example/index3.ts | 60 +++++++++++++++++++++++++++++++++++++++++++++++ src/index.ts | 6 +++-- 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 example/index3.ts diff --git a/example/index3.ts b/example/index3.ts new file mode 100644 index 0000000..047339e --- /dev/null +++ b/example/index3.ts @@ -0,0 +1,60 @@ +import { Elysia, InternalRoute } from 'elysia' +import { swagger } from '../src/index' +import { plugin } from './plugin' +import { registerSchemaPath } from '../src/utils' + +const app = new Elysia() + .use( + swagger({ + provider: 'scalar', + documentation: { + info: { + title: 'Elysia Scalar', + version: '0.8.1' + }, + tags: [ + { + name: 'Test', + description: 'Hello' + } + ], + paths: { + "/b/": { + get: { + operationId: "getB", + summary: "Ping Pong B", + description: "Lorem Ipsum Dolar", + tags: [ "Test" ], + responses: { + "200": { + description: "test" + }, + }, + }, + }, + }, + components: { + schemas: { + User: { + description: 'string' + } + }, + securitySchemes: { + JwtAuth: { + type: 'http', + scheme: 'bearer', + bearerFormat: 'JWT', + description: 'Enter JWT Bearer token **_only_**' + } + } + } + }, + swaggerOptions: { + persistAuthorization: true + } + }) + ) + .use(plugin) + .listen(3000) + +console.log(app.rsaoutes) diff --git a/src/index.ts b/src/index.ts index b585d7b..c235e4f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -143,10 +143,12 @@ export const swagger = ...documentation.info } }, - paths: filterPaths(schema, { + paths: {...filterPaths(schema, { excludeStaticFile, exclude: Array.isArray(exclude) ? exclude : [exclude] - }), + }), + ...documentation.paths + }, components: { ...documentation.components, schemas: {