klasik 1.0.14 → 1.0.16

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
@@ -334,6 +334,8 @@ output/
334
334
  ### Supported Reference Types
335
335
 
336
336
  - **Relative paths**: `./schemas/user.yaml`, `../common/types.yaml`
337
+ - When the main spec is from a remote URL, relative paths are resolved against the spec's URL
338
+ - Example: spec at `https://raw.githubusercontent.com/org/repo/main/api/openapi.yaml` with ref `./schemas/user.yaml` resolves to `https://raw.githubusercontent.com/org/repo/main/api/schemas/user.yaml`
337
339
  - **Remote URLs**: `https://api.example.com/schemas/user.yaml`
338
340
  - **Mixed**: Main spec from HTTPS, references can be relative or absolute
339
341
 
@@ -62,7 +62,7 @@ export declare class SpecDownloader {
62
62
  */
63
63
  cleanupTemp(): void;
64
64
  /**
65
- * Get base URL from a full URL (removes the filename)
65
+ * Get base URL from a full URL (removes the filename and ensures trailing slash)
66
66
  */
67
67
  private getBaseUrl;
68
68
  /**
@@ -233,14 +233,16 @@ class SpecDownloader {
233
233
  }
234
234
  }
235
235
  /**
236
- * Get base URL from a full URL (removes the filename)
236
+ * Get base URL from a full URL (removes the filename and ensures trailing slash)
237
237
  */
238
238
  getBaseUrl(url) {
239
239
  try {
240
240
  const urlObj = new URL(url);
241
241
  const pathParts = urlObj.pathname.split('/');
242
242
  pathParts.pop(); // Remove filename
243
- urlObj.pathname = pathParts.join('/');
243
+ // Ensure the path ends with a slash for proper relative URL resolution
244
+ const basePath = pathParts.join('/');
245
+ urlObj.pathname = basePath.endsWith('/') ? basePath : basePath + '/';
244
246
  return urlObj.toString();
245
247
  }
246
248
  catch {
@@ -345,6 +347,10 @@ class SpecDownloader {
345
347
  outputPath = path.resolve(specDir, ref.split('#')[0]);
346
348
  }
347
349
  console.log(` - Downloading reference: ${ref}`);
350
+ if (isRemoteSpec && baseUrl) {
351
+ console.log(` Base URL: ${baseUrl}`);
352
+ console.log(` Resolved to: ${refUrl}`);
353
+ }
348
354
  try {
349
355
  // Ensure output directory exists
350
356
  const outputDir = path.dirname(outputPath);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "klasik",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "Download OpenAPI specs from remote URLs and generate TypeScript clients with class-transformer support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",