From 0cb5887e91dde792b807cc3d7f0862042f5287a0 Mon Sep 17 00:00:00 2001 From: Ian Sinnott Date: Sat, 29 Jul 2023 21:21:20 +0800 Subject: [PATCH] feat: allow configuring the path of the openapi json spec --- src/index.ts | 10 ++++++++-- src/types.ts | 8 ++++++++ test/index.test.ts | 13 +++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index eefbfbd..cfe7f8e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,12 +17,14 @@ export const swagger = version = '4.18.2', excludeStaticFile = true, path = '/swagger' as Path, + specPathname = 'json', exclude = [] }: ElysiaSwaggerConfig = { documentation: {}, version: '4.18.2', excludeStaticFile: true, path: '/swagger' as Path, + specPathname: 'json', exclude: [] } ) => @@ -33,6 +35,10 @@ export const swagger = version: '0.0.0', ...documentation.info } + + if (specPathname.startsWith('/')) { + specPathname = specPathname.slice(1) + } app.get(path, (context) => { return new Response( @@ -58,7 +64,7 @@ export const swagger =