feat: specify the api's auth type (#2715)

This commit is contained in:
Finley Ge
2024-09-15 13:06:51 +08:00
committed by shilin66
parent f5359874c8
commit a1096fee6a
5 changed files with 103 additions and 25 deletions

View File

@@ -213,7 +213,10 @@ function getMethod(api: ApiType): 'GET' | 'POST' {
export function parseAPI({ path, rootPath }: { path: string; rootPath: string }): ApiType {
const code = fs.readFileSync(path, 'utf-8');
const authApiKey = code.includes('authApiKey: true');
const authToken = code.includes('authToken: true');
const api = parseCode(code);
api.authorization = authApiKey ? 'apikey' : authToken ? 'token' : undefined;
api.url = path.replace('.ts', '').replace(rootPath, '');
api.path = path;
if (api.method === undefined) {