fix(openapi): guard suffix matching and add ambient context test

This commit is contained in:
Lucas Winther committed 2026-09-06 19:49:13 +02:00
1 parent 25fc2c9057
commit 69f2a95371
2 files changed
+17 -6

No files matched your search

+4 -1
View File
@@ -98,9 +98,12 @@ export async function getOpenApiSpec(
// 2. Specific path lookup
if (options?.path) {
const target = normalizePath(options.path);
const suffix = target.replace(/^\/api\/v3/, "");
const matchedKey =
allPaths.find((p) => p.toLowerCase() === target) ||
allPaths.find((p) => p.toLowerCase().endsWith(target.replace(/^\/api\/v3/, "")));
(suffix.length > 0 && suffix !== "/"
? allPaths.find((p) => p.toLowerCase().endsWith(suffix))
: undefined);
if (!matchedKey || !doc.paths[matchedKey]) {
const sample = allPaths.slice(0, 10).join(", ");