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/README.md CHANGED
@@ -564,7 +564,7 @@ await generate({
564
564
 
565
565
  Full support for OpenAPI 3.0 and 3.1 specifications, including:
566
566
 
567
- - `$ref` resolution across the document
567
+ - `$ref` resolution across the document, including multi-file specs with external `$ref` paths (e.g. `$ref: './paths/users.yaml'`)
568
568
  - `components.schemas` mapped to TypeScript types and optional Zod schemas
569
569
  - `servers[0].url` used as the default base URL
570
570
  - All HTTP methods: GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
@@ -575,7 +575,7 @@ Full support for OpenAPI 3.0 and 3.1 specifications, including:
575
575
  - Tag-based grouping of generated hooks
576
576
  - `x-pagination` vendor extension for explicit pagination hints
577
577
 
578
- **Supported file formats:** `.yaml`, `.yml`, `.json`
578
+ **Supported file formats:** `.yaml`, `.yml`, `.json` (single-file or multi-file with relative `$ref` references)
579
579
 
580
580
  ### Swagger 2.0
581
581
 
@@ -584,8 +584,9 @@ Full support for Swagger 2.0 specifications, including:
584
584
  - `definitions` mapped to TypeScript types
585
585
  - `host` + `basePath` combined into the base URL
586
586
  - All standard Swagger features (parameters, responses, tags)
587
+ - Multi-file specs with external `$ref` paths
587
588
 
588
- **Supported file formats:** `.yaml`, `.yml`, `.json`
589
+ **Supported file formats:** `.yaml`, `.yml`, `.json` (single-file or multi-file with relative `$ref` references)
589
590
 
590
591
  ### GraphQL
591
592
 
package/dist/cli.js CHANGED
@@ -454,7 +454,7 @@ var openApiParser = {
454
454
  },
455
455
  async parse(input, options) {
456
456
  const derefed = await SwaggerParser.dereference(
457
- input,
457
+ options?.filePath ?? input,
458
458
  { dereference: { circular: "ignore" } }
459
459
  );
460
460
  const doc = derefed;
@@ -789,7 +789,7 @@ var swaggerParser = {
789
789
  },
790
790
  async parse(input, options) {
791
791
  const derefed = await SwaggerParser.dereference(
792
- input,
792
+ options?.filePath ?? input,
793
793
  { dereference: { circular: "ignore" } }
794
794
  );
795
795
  const doc = derefed;
@@ -1215,9 +1215,14 @@ async function parseSpec(input, options) {
1215
1215
  } else {
1216
1216
  resolved = input;
1217
1217
  }
1218
+ const resolvedOptions = { ...options };
1219
+ if (typeof input === "string" && /\.[a-z]{2,10}$/i.test(input) && !input.includes("\n")) {
1220
+ const { resolve } = await import('path');
1221
+ resolvedOptions.filePath = resolve(input);
1222
+ }
1218
1223
  for (const parser of parsers) {
1219
1224
  if (parser.canParse(resolved)) {
1220
- const spec = await parser.parse(resolved, options);
1225
+ const spec = await parser.parse(resolved, resolvedOptions);
1221
1226
  return applyPaginationDetection(spec);
1222
1227
  }
1223
1228
  }