auto-api-hooks 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -156,6 +156,8 @@ interface HookGenerator {
156
156
 
157
157
  interface ParseOptions {
158
158
  baseUrl?: string;
159
+ /** @internal Original file path, used to resolve relative $ref pointers */
160
+ filePath?: string;
159
161
  }
160
162
 
161
163
  /**
package/dist/index.d.ts CHANGED
@@ -156,6 +156,8 @@ interface HookGenerator {
156
156
 
157
157
  interface ParseOptions {
158
158
  baseUrl?: string;
159
+ /** @internal Original file path, used to resolve relative $ref pointers */
160
+ filePath?: string;
159
161
  }
160
162
 
161
163
  /**
package/dist/index.js CHANGED
@@ -430,7 +430,7 @@ var openApiParser = {
430
430
  },
431
431
  async parse(input, options) {
432
432
  const derefed = await SwaggerParser.dereference(
433
- input,
433
+ options?.filePath ?? input,
434
434
  { dereference: { circular: "ignore" } }
435
435
  );
436
436
  const doc = derefed;
@@ -765,7 +765,7 @@ var swaggerParser = {
765
765
  },
766
766
  async parse(input, options) {
767
767
  const derefed = await SwaggerParser.dereference(
768
- input,
768
+ options?.filePath ?? input,
769
769
  { dereference: { circular: "ignore" } }
770
770
  );
771
771
  const doc = derefed;
@@ -1191,9 +1191,14 @@ async function parseSpec(input, options) {
1191
1191
  } else {
1192
1192
  resolved = input;
1193
1193
  }
1194
+ const resolvedOptions = { ...options };
1195
+ if (typeof input === "string" && /\.[a-z]{2,10}$/i.test(input) && !input.includes("\n")) {
1196
+ const { resolve } = await import('path');
1197
+ resolvedOptions.filePath = resolve(input);
1198
+ }
1194
1199
  for (const parser of parsers) {
1195
1200
  if (parser.canParse(resolved)) {
1196
- const spec = await parser.parse(resolved, options);
1201
+ const spec = await parser.parse(resolved, resolvedOptions);
1197
1202
  return applyPaginationDetection(spec);
1198
1203
  }
1199
1204
  }