From b8b0691980273c1aaea71289bd78046221c19252 Mon Sep 17 00:00:00 2001 From: solufa Date: Fri, 16 Aug 2024 12:24:51 +0900 Subject: [PATCH] fix: normalize root path --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 927751c..e5418e7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -84,7 +84,7 @@ type AllMethods = [${paths.map((_, i) => `Methods${i}`).join(', ')}]`; path = path.replace(/\/_([^/@]+)(@[^/]+)?/g, '/{$1}'); } - path = path.replace(config.input, ''); + path = path.replace(config.input, '') || '/'; doc.paths![path] = Object.entries(def.properties!).reduce((dict, [method, val]) => { const params = [...parameters]; @@ -122,7 +122,7 @@ type AllMethods = [${paths.map((_, i) => `Methods${i}`).join(', ')}]`; return { ...dict, [method]: { - tags: path.replace(config.input, '').split('/{')[0].replace(/^\//, '').split('/'), + tags: path === '/' ? undefined : path.split('/{')[0].replace(/^\//, '').split('/'), parameters: params, requestBody: props.reqBody === undefined