swagger-to-playwright-api-clients 1.0.15 → 1.0.17

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.
@@ -1 +1 @@
1
- {"version":3,"file":"copyBaseClient.d.ts","sourceRoot":"","sources":["../../src/utils/copyBaseClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiTH;;GAEG;AACH,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYvE"}
1
+ {"version":3,"file":"copyBaseClient.d.ts","sourceRoot":"","sources":["../../src/utils/copyBaseClient.ts"],"names":[],"mappings":"AAAA;;GAEG;AAsSH;;GAEG;AACH,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYvE"}
@@ -44,7 +44,7 @@ const fs = __importStar(require("fs"));
44
44
  const path = __importStar(require("path"));
45
45
  const logger_1 = __importDefault(require("./logger"));
46
46
  /**
47
- * BaseAPIClient template content - uses winston.Logger
47
+ * BaseAPIClient template content - uses swagger-to-playwright-api-clients Logger
48
48
  */
49
49
  const BASE_API_CLIENT_CONTENT = `/**
50
50
  * BaseAPIClient - Base class for making API requests using Playwright's APIRequestContext
@@ -52,7 +52,7 @@ const BASE_API_CLIENT_CONTENT = `/**
52
52
  */
53
53
 
54
54
  import { request, APIRequestContext } from '@playwright/test';
55
- import type { Logger } from 'winston';
55
+ import { logger } from 'swagger-to-playwright-api-clients';
56
56
 
57
57
  /**
58
58
  * Supported query parameter value types
@@ -79,29 +79,18 @@ export interface APIResponseResult<T = unknown> {
79
79
 
80
80
  /**
81
81
  * BaseAPIClient - Provides HTTP methods using Playwright's request API
82
- *
83
- * @example
84
- * // Without logging
85
- * const client = new BaseAPIClient('https://api.example.com');
86
- *
87
- * // With Winston logger from the library
88
- * import { getLogger } from 'swagger-to-playwright-api-clients';
89
- * const client = new BaseAPIClient('https://api.example.com', {}, getLogger());
90
82
  */
91
83
  export class BaseAPIClient {
92
84
  private baseURL: string;
93
85
  private defaultHeaders: Record<string, string>;
94
86
  private context: APIRequestContext | null = null;
95
- private logger?: Logger;
96
87
 
97
88
  constructor(
98
89
  baseURL: string,
99
90
  defaultHeaders: Record<string, string> = {},
100
- logger?: Logger
101
91
  ) {
102
92
  this.baseURL = baseURL;
103
93
  this.defaultHeaders = defaultHeaders;
104
- this.logger = logger;
105
94
  }
106
95
 
107
96
  /**
@@ -112,7 +101,7 @@ export class BaseAPIClient {
112
101
  baseURL: this.baseURL,
113
102
  extraHTTPHeaders: this.defaultHeaders,
114
103
  });
115
- this.logger?.info(\`BaseAPIClient initialized with baseURL: \${this.baseURL}\`);
104
+ logger.info(\`BaseAPIClient initialized with baseURL: \${this.baseURL}\`);
116
105
  }
117
106
 
118
107
  /**
@@ -122,7 +111,7 @@ export class BaseAPIClient {
122
111
  if (this.context) {
123
112
  await this.context.dispose();
124
113
  this.context = null;
125
- this.logger?.info('BaseAPIClient disposed');
114
+ logger.info('BaseAPIClient disposed');
126
115
  }
127
116
  }
128
117
 
@@ -173,11 +162,11 @@ export class BaseAPIClient {
173
162
  headers?: Record<string, string>,
174
163
  body?: unknown
175
164
  ): void {
176
- this.logger?.info(\`>>> \${method} \${this.baseURL}\${url}\`);
165
+ logger.info(\`>>> \${method} \${this.baseURL}\${url}\`);
177
166
  const allHeaders = { ...this.defaultHeaders, ...headers };
178
- this.logger?.debug(\`Headers: \${JSON.stringify(allHeaders, null, 2)}\`);
167
+ logger.debug(\`Headers: \${JSON.stringify(allHeaders, null, 2)}\`);
179
168
  if (body !== undefined) {
180
- this.logger?.info(\`Body: \${JSON.stringify(body, null, 2)}\`);
169
+ logger.info(\`Body: \${JSON.stringify(body, null, 2)}\`);
181
170
  }
182
171
  }
183
172
 
@@ -185,8 +174,8 @@ export class BaseAPIClient {
185
174
  * Log response details
186
175
  */
187
176
  private logResponse<T>(method: string, url: string, status: number, body: T): void {
188
- this.logger?.info(\`<<< \${method} \${this.baseURL}\${url} - Status: \${status}\`);
189
- this.logger?.info(\`Response: \${JSON.stringify(body, null, 2)}\`);
177
+ logger.info(\`<<< \${method} \${this.baseURL}\${url} - Status: \${status}\`);
178
+ logger.info(\`Response: \${JSON.stringify(body, null, 2)}\`);
190
179
  }
191
180
 
192
181
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"copyBaseClient.js","sourceRoot":"","sources":["../../src/utils/copyBaseClient.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoTH,wCAYC;AA9TD,uCAAyB;AACzB,2CAA6B;AAC7B,sDAA8B;AAE9B;;GAEG;AACH,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsS/B,CAAC;AAEF;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,SAAiB;IACrD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAE5D,0BAA0B;IAC1B,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAExD,iBAAiB;IACjB,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,uBAAuB,EAAE,OAAO,CAAC,CAAC;IAE1E,gBAAM,CAAC,IAAI,CAAC,4BAA4B,UAAU,EAAE,CAAC,CAAC;IAEtD,OAAO,UAAU,CAAC;AACnB,CAAC"}
1
+ {"version":3,"file":"copyBaseClient.js","sourceRoot":"","sources":["../../src/utils/copyBaseClient.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAySH,wCAYC;AAnTD,uCAAyB;AACzB,2CAA6B;AAC7B,sDAA8B;AAE9B;;GAEG;AACH,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2R/B,CAAC;AAEF;;GAEG;AACI,KAAK,UAAU,cAAc,CAAC,SAAiB;IACrD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IAE5D,0BAA0B;IAC1B,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAExD,iBAAiB;IACjB,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,uBAAuB,EAAE,OAAO,CAAC,CAAC;IAE1E,gBAAM,CAAC,IAAI,CAAC,4BAA4B,UAAU,EAAE,CAAC,CAAC;IAEtD,OAAO,UAAU,CAAC;AACnB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-to-playwright-api-clients",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "Generate TypeScript API clients from Swagger/OpenAPI specifications for Playwright testing",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",