File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed
Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -146,7 +146,7 @@ export const swagger =
146146 ...documentation . info
147147 }
148148 } ,
149- paths : { ...filterPaths ( schema , {
149+ paths : { ...filterPaths ( schema , relativePath , {
150150 excludeStaticFile,
151151 exclude : Array . isArray ( exclude ) ? exclude : [ exclude ]
152152 } ) ,
Original file line number Diff line number Diff line change 11/* eslint-disable @typescript-eslint/ban-ts-comment */
22/* eslint-disable @typescript-eslint/no-unused-vars */
3+ import path from 'path'
34import type { HTTPMethod , LocalHook } from 'elysia'
45
56import { Kind , type TSchema } from '@sinclair/typebox'
@@ -282,6 +283,7 @@ export const registerSchemaPath = ({
282283
283284export const filterPaths = (
284285 paths : Record < string , any > ,
286+ docsPath : string ,
285287 {
286288 excludeStaticFile = true ,
287289 exclude = [ ]
@@ -292,14 +294,19 @@ export const filterPaths = (
292294) => {
293295 const newPaths : Record < string , any > = { }
294296
297+ // exclude docs path and OpenAPI json path
298+ const excludePaths = [ `/${ docsPath } ` , `/${ docsPath } /json` ] . map ( ( p ) =>
299+ path . normalize ( p )
300+ )
301+
295302 for ( const [ key , value ] of Object . entries ( paths ) )
296303 if (
297304 ! exclude . some ( ( x ) => {
298305 if ( typeof x === 'string' ) return key === x
299306
300307 return x . test ( key )
301308 } ) &&
302- ! key . includes ( '/swagger' ) &&
309+ ! excludePaths . includes ( key ) &&
303310 ! key . includes ( '*' ) &&
304311 ( excludeStaticFile ? ! key . includes ( '.' ) : true )
305312 ) {
You can’t perform that action at this time.
0 commit comments