@cerios/openapi-to-zod 0.6.0 → 1.0.0
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 +270 -51
- package/dist/cli.js +234 -164
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +290 -202
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +9 -344
- package/dist/index.d.ts +9 -344
- package/dist/index.js +39 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +200 -0
- package/dist/internal.d.ts +200 -0
- package/dist/internal.js +464 -0
- package/dist/internal.js.map +1 -0
- package/dist/internal.mjs +422 -0
- package/dist/internal.mjs.map +1 -0
- package/dist/types-BjoP91vk.d.mts +314 -0
- package/dist/types-BjoP91vk.d.ts +314 -0
- package/package.json +21 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { O as OpenApiGeneratorOptions } from './types-BjoP91vk.js';
|
|
2
|
+
export { C as CommonSchemaOptions, a as ConfigFile, E as ExecutionMode, b as OpenAPISchema, c as OpenAPISpec, d as OperationFilters, R as RequestOptions, e as ResponseOptions, f as defineConfig } from './types-BjoP91vk.js';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Custom error classes for better error handling and debugging
|
|
3
6
|
*/
|
|
@@ -50,298 +53,6 @@ declare class CliOptionsError extends GeneratorError {
|
|
|
50
53
|
constructor(message: string, context?: Record<string, unknown>);
|
|
51
54
|
}
|
|
52
55
|
|
|
53
|
-
/**
|
|
54
|
-
* Common options shared by both request and response contexts
|
|
55
|
-
*/
|
|
56
|
-
interface CommonSchemaOptions {
|
|
57
|
-
/**
|
|
58
|
-
* Object validation mode
|
|
59
|
-
* - 'strict': Uses z.strictObject() - no additional properties allowed
|
|
60
|
-
* - 'normal': Uses z.object() - additional properties allowed
|
|
61
|
-
* - 'loose': Uses z.looseObject() - explicitly allows additional properties
|
|
62
|
-
*/
|
|
63
|
-
mode?: "strict" | "normal" | "loose";
|
|
64
|
-
/**
|
|
65
|
-
* Whether to add .describe() calls for better error messages
|
|
66
|
-
* @default false
|
|
67
|
-
*/
|
|
68
|
-
useDescribe?: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* Whether to include descriptions as JSDoc comments
|
|
71
|
-
*/
|
|
72
|
-
includeDescriptions?: boolean;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Request-specific options that can override root-level options
|
|
76
|
-
*/
|
|
77
|
-
interface RequestOptions extends CommonSchemaOptions {
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Response-specific options that can override root-level options
|
|
81
|
-
*/
|
|
82
|
-
interface ResponseOptions extends CommonSchemaOptions {
|
|
83
|
-
}
|
|
84
|
-
interface OpenApiGeneratorOptions {
|
|
85
|
-
/**
|
|
86
|
-
* Object validation mode
|
|
87
|
-
* - 'strict': Uses z.strictObject() - no additional properties allowed
|
|
88
|
-
* - 'normal': Uses z.object() - additional properties allowed
|
|
89
|
-
* - 'loose': Uses z.looseObject() - explicitly allows additional properties
|
|
90
|
-
*/
|
|
91
|
-
mode?: "strict" | "normal" | "loose";
|
|
92
|
-
/**
|
|
93
|
-
* Input OpenAPI YAML file path
|
|
94
|
-
*/
|
|
95
|
-
input: string;
|
|
96
|
-
/**
|
|
97
|
-
* Output TypeScript file path
|
|
98
|
-
* Optional when using string generation methods (generateString)
|
|
99
|
-
* Required when calling generate() to write to a file
|
|
100
|
-
*/
|
|
101
|
-
output?: string;
|
|
102
|
-
/**
|
|
103
|
-
* Whether to include descriptions as JSDoc comments
|
|
104
|
-
*/
|
|
105
|
-
includeDescriptions?: boolean;
|
|
106
|
-
/**
|
|
107
|
-
* Whether to add .describe() calls for better error messages
|
|
108
|
-
* @default false
|
|
109
|
-
*/
|
|
110
|
-
useDescribe?: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* Schema filtering mode
|
|
113
|
-
* - 'all': Generate all schemas (default)
|
|
114
|
-
* - 'request': Only include schemas suitable for requests (excludes readOnly)
|
|
115
|
-
* - 'response': Only include schemas suitable for responses (excludes writeOnly)
|
|
116
|
-
*/
|
|
117
|
-
schemaType?: "all" | "request" | "response";
|
|
118
|
-
/**
|
|
119
|
-
* Prefix to add to all generated schema names
|
|
120
|
-
* @example "api" -> "apiUserSchema"
|
|
121
|
-
*/
|
|
122
|
-
prefix?: string;
|
|
123
|
-
/**
|
|
124
|
-
* Suffix to add before "Schema" in generated names
|
|
125
|
-
* @example "dto" -> "userDtoSchema"
|
|
126
|
-
*/
|
|
127
|
-
suffix?: string;
|
|
128
|
-
/**
|
|
129
|
-
* Whether to include generation statistics in output file
|
|
130
|
-
* @default true
|
|
131
|
-
*/
|
|
132
|
-
showStats?: boolean;
|
|
133
|
-
/**
|
|
134
|
-
* Request-specific options that override root-level options
|
|
135
|
-
* Applied when schemas are used in request contexts
|
|
136
|
-
*/
|
|
137
|
-
request?: RequestOptions;
|
|
138
|
-
/**
|
|
139
|
-
* Response-specific options that override root-level options
|
|
140
|
-
* Applied when schemas are used in response contexts
|
|
141
|
-
*/
|
|
142
|
-
response?: ResponseOptions;
|
|
143
|
-
/**
|
|
144
|
-
* Filter which operations to include/exclude from generation
|
|
145
|
-
* Useful for generating separate schemas for different API subsets
|
|
146
|
-
*
|
|
147
|
-
* Filtering logic:
|
|
148
|
-
* 1. If no filters specified, all operations are included
|
|
149
|
-
* 2. Empty arrays are treated as "no constraint" (not as "exclude all")
|
|
150
|
-
* 3. Include filters are applied first (allowlist)
|
|
151
|
-
* 4. Exclude filters are applied second (blocklist)
|
|
152
|
-
* 5. Exclude rules always win over include rules
|
|
153
|
-
*
|
|
154
|
-
* Supports glob patterns for paths and operationIds (e.g., "/api/v1/**", "get*")
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* // Only generate schemas for user-related endpoints
|
|
158
|
-
* operationFilters: {
|
|
159
|
-
* includeTags: ["users"]
|
|
160
|
-
* }
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* // Generate only GET endpoints, excluding deprecated ones
|
|
164
|
-
* operationFilters: {
|
|
165
|
-
* includeMethods: ["get"],
|
|
166
|
-
* excludeDeprecated: true
|
|
167
|
-
* }
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* // Generate only v1 API endpoints
|
|
171
|
-
* operationFilters: {
|
|
172
|
-
* includePaths: ["/api/v1/**"]
|
|
173
|
-
* }
|
|
174
|
-
*/
|
|
175
|
-
operationFilters?: OperationFilters;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Operation filtering options
|
|
179
|
-
* Controls which operations from the OpenAPI spec are included in generation
|
|
180
|
-
*/
|
|
181
|
-
interface OperationFilters {
|
|
182
|
-
/**
|
|
183
|
-
* Include only operations with these tags
|
|
184
|
-
* If specified, only operations with at least one matching tag are included
|
|
185
|
-
* Empty array = no constraint
|
|
186
|
-
*/
|
|
187
|
-
includeTags?: string[];
|
|
188
|
-
/**
|
|
189
|
-
* Exclude operations with these tags
|
|
190
|
-
* Operations with any matching tag are excluded
|
|
191
|
-
* Empty array = no constraint
|
|
192
|
-
*/
|
|
193
|
-
excludeTags?: string[];
|
|
194
|
-
/**
|
|
195
|
-
* Include only operations matching these path patterns
|
|
196
|
-
* Supports glob patterns (e.g., "/users/**", "/api/v1/*")
|
|
197
|
-
* Empty array = no constraint
|
|
198
|
-
*/
|
|
199
|
-
includePaths?: string[];
|
|
200
|
-
/**
|
|
201
|
-
* Exclude operations matching these path patterns
|
|
202
|
-
* Supports glob patterns (e.g., "/internal/**", "/admin/*")
|
|
203
|
-
* Empty array = no constraint
|
|
204
|
-
*/
|
|
205
|
-
excludePaths?: string[];
|
|
206
|
-
/**
|
|
207
|
-
* Include only these HTTP methods
|
|
208
|
-
* Valid values: "get", "post", "put", "patch", "delete", "head", "options"
|
|
209
|
-
* Empty array = no constraint
|
|
210
|
-
*/
|
|
211
|
-
includeMethods?: string[];
|
|
212
|
-
/**
|
|
213
|
-
* Exclude these HTTP methods
|
|
214
|
-
* Valid values: "get", "post", "put", "patch", "delete", "head", "options"
|
|
215
|
-
* Empty array = no constraint
|
|
216
|
-
*/
|
|
217
|
-
excludeMethods?: string[];
|
|
218
|
-
/**
|
|
219
|
-
* Include only operations matching these operationId patterns
|
|
220
|
-
* Supports glob patterns (e.g., "getUser*", "*Admin")
|
|
221
|
-
* Empty array = no constraint
|
|
222
|
-
*/
|
|
223
|
-
includeOperationIds?: string[];
|
|
224
|
-
/**
|
|
225
|
-
* Exclude operations matching these operationId patterns
|
|
226
|
-
* Supports glob patterns (e.g., "deleteUser*", "*Internal")
|
|
227
|
-
* Empty array = no constraint
|
|
228
|
-
*/
|
|
229
|
-
excludeOperationIds?: string[];
|
|
230
|
-
/**
|
|
231
|
-
* Whether to exclude deprecated operations
|
|
232
|
-
* @default false
|
|
233
|
-
*/
|
|
234
|
-
excludeDeprecated?: boolean;
|
|
235
|
-
}
|
|
236
|
-
interface OpenAPISchema {
|
|
237
|
-
type?: string | string[];
|
|
238
|
-
format?: string;
|
|
239
|
-
enum?: (string | number)[];
|
|
240
|
-
const?: string | number | boolean | null;
|
|
241
|
-
properties?: Record<string, OpenAPISchema>;
|
|
242
|
-
required?: string[];
|
|
243
|
-
items?: OpenAPISchema;
|
|
244
|
-
prefixItems?: OpenAPISchema[];
|
|
245
|
-
allOf?: OpenAPISchema[];
|
|
246
|
-
oneOf?: OpenAPISchema[];
|
|
247
|
-
anyOf?: OpenAPISchema[];
|
|
248
|
-
$ref?: string;
|
|
249
|
-
nullable?: boolean;
|
|
250
|
-
minLength?: number;
|
|
251
|
-
maxLength?: number;
|
|
252
|
-
minimum?: number;
|
|
253
|
-
maximum?: number;
|
|
254
|
-
exclusiveMinimum?: boolean | number;
|
|
255
|
-
exclusiveMaximum?: boolean | number;
|
|
256
|
-
multipleOf?: number;
|
|
257
|
-
pattern?: string;
|
|
258
|
-
description?: string;
|
|
259
|
-
title?: string;
|
|
260
|
-
example?: any;
|
|
261
|
-
examples?: any[];
|
|
262
|
-
additionalProperties?: boolean | OpenAPISchema;
|
|
263
|
-
minProperties?: number;
|
|
264
|
-
maxProperties?: number;
|
|
265
|
-
minItems?: number;
|
|
266
|
-
maxItems?: number;
|
|
267
|
-
uniqueItems?: boolean;
|
|
268
|
-
contains?: OpenAPISchema;
|
|
269
|
-
minContains?: number;
|
|
270
|
-
maxContains?: number;
|
|
271
|
-
discriminator?: {
|
|
272
|
-
propertyName: string;
|
|
273
|
-
mapping?: Record<string, string>;
|
|
274
|
-
};
|
|
275
|
-
readOnly?: boolean;
|
|
276
|
-
writeOnly?: boolean;
|
|
277
|
-
deprecated?: boolean;
|
|
278
|
-
dependentRequired?: Record<string, string[]>;
|
|
279
|
-
dependencies?: Record<string, string[] | OpenAPISchema>;
|
|
280
|
-
patternProperties?: Record<string, OpenAPISchema>;
|
|
281
|
-
propertyNames?: OpenAPISchema;
|
|
282
|
-
contentMediaType?: string;
|
|
283
|
-
contentEncoding?: string;
|
|
284
|
-
not?: OpenAPISchema;
|
|
285
|
-
if?: OpenAPISchema;
|
|
286
|
-
then?: OpenAPISchema;
|
|
287
|
-
else?: OpenAPISchema;
|
|
288
|
-
unevaluatedProperties?: boolean | OpenAPISchema;
|
|
289
|
-
unevaluatedItems?: boolean | OpenAPISchema;
|
|
290
|
-
}
|
|
291
|
-
interface OpenAPISpec {
|
|
292
|
-
components?: {
|
|
293
|
-
schemas?: Record<string, OpenAPISchema>;
|
|
294
|
-
};
|
|
295
|
-
paths?: Record<string, any>;
|
|
296
|
-
}
|
|
297
|
-
/**
|
|
298
|
-
* Execution mode for batch processing
|
|
299
|
-
* - 'parallel': Process all specs concurrently (default, faster)
|
|
300
|
-
* - 'sequential': Process specs one at a time (safer for resource constraints)
|
|
301
|
-
*/
|
|
302
|
-
type ExecutionMode = "parallel" | "sequential";
|
|
303
|
-
/**
|
|
304
|
-
* Root configuration file structure
|
|
305
|
-
*/
|
|
306
|
-
interface ConfigFile {
|
|
307
|
-
/**
|
|
308
|
-
* Global default options applied to all specs
|
|
309
|
-
* Can be overridden by individual spec configurations
|
|
310
|
-
*/
|
|
311
|
-
defaults?: Partial<Omit<OpenApiGeneratorOptions, "input" | "output">>;
|
|
312
|
-
/**
|
|
313
|
-
* Array of OpenAPI specifications to process
|
|
314
|
-
* Each spec must have input and output paths
|
|
315
|
-
*/
|
|
316
|
-
specs: OpenApiGeneratorOptions[];
|
|
317
|
-
/**
|
|
318
|
-
* Execution mode for batch processing
|
|
319
|
-
* @default "parallel"
|
|
320
|
-
*/
|
|
321
|
-
executionMode?: ExecutionMode;
|
|
322
|
-
}
|
|
323
|
-
/**
|
|
324
|
-
* Helper function for type-safe config file creation
|
|
325
|
-
* Provides IDE autocomplete and type checking for config files
|
|
326
|
-
*
|
|
327
|
-
* @example
|
|
328
|
-
* ```typescript
|
|
329
|
-
* import { defineConfig } from '@cerios/openapi-to-zod';
|
|
330
|
-
*
|
|
331
|
-
* export default defineConfig({
|
|
332
|
-
* defaults: {
|
|
333
|
-
* mode: 'strict',
|
|
334
|
-
* includeDescriptions: true
|
|
335
|
-
* },
|
|
336
|
-
* specs: [
|
|
337
|
-
* { input: 'api-v1.yaml', output: 'schemas/v1.ts' },
|
|
338
|
-
* { input: 'api-v2.yaml', output: 'schemas/v2.ts', mode: 'normal' }
|
|
339
|
-
* ]
|
|
340
|
-
* });
|
|
341
|
-
* ```
|
|
342
|
-
*/
|
|
343
|
-
declare function defineConfig(config: ConfigFile): ConfigFile;
|
|
344
|
-
|
|
345
56
|
declare class OpenApiGenerator {
|
|
346
57
|
private schemas;
|
|
347
58
|
private types;
|
|
@@ -414,6 +125,11 @@ declare class OpenApiGenerator {
|
|
|
414
125
|
* Generate query parameter schemas for each operation
|
|
415
126
|
*/
|
|
416
127
|
private generateQueryParameterSchemas;
|
|
128
|
+
/**
|
|
129
|
+
* Check if a header should be ignored based on filter patterns
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
private shouldIgnoreHeader;
|
|
417
133
|
/**
|
|
418
134
|
* Generate header parameter schemas for each operation
|
|
419
135
|
* Header parameters are always string type (HTTP header semantics)
|
|
@@ -434,55 +150,4 @@ declare class OpenApiGenerator {
|
|
|
434
150
|
private generateStats;
|
|
435
151
|
}
|
|
436
152
|
|
|
437
|
-
|
|
438
|
-
* Filter statistics to track which operations were included/excluded
|
|
439
|
-
*/
|
|
440
|
-
interface FilterStatistics {
|
|
441
|
-
totalOperations: number;
|
|
442
|
-
includedOperations: number;
|
|
443
|
-
filteredByTags: number;
|
|
444
|
-
filteredByPaths: number;
|
|
445
|
-
filteredByMethods: number;
|
|
446
|
-
filteredByOperationIds: number;
|
|
447
|
-
filteredByDeprecated: number;
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Create a new filter statistics object with all counters initialized to zero
|
|
451
|
-
*/
|
|
452
|
-
declare function createFilterStatistics(): FilterStatistics;
|
|
453
|
-
/**
|
|
454
|
-
* Determine if an operation should be included based on filter criteria
|
|
455
|
-
*
|
|
456
|
-
* Filter logic:
|
|
457
|
-
* 1. If no filters specified, include all operations
|
|
458
|
-
* 2. Empty arrays are treated as "no constraint" (not as "exclude all")
|
|
459
|
-
* 3. Include filters are applied first (allowlist)
|
|
460
|
-
* 4. Exclude filters are applied second (blocklist)
|
|
461
|
-
* 5. Exclude rules always win over include rules
|
|
462
|
-
*
|
|
463
|
-
* @param operation - The OpenAPI operation object
|
|
464
|
-
* @param path - The operation path (e.g., "/users/{id}")
|
|
465
|
-
* @param method - The HTTP method (e.g., "get", "post")
|
|
466
|
-
* @param filters - Optional filter configuration
|
|
467
|
-
* @param stats - Optional statistics object to track filtering reasons
|
|
468
|
-
* @returns true if the operation should be included, false otherwise
|
|
469
|
-
*/
|
|
470
|
-
declare function shouldIncludeOperation(operation: any, path: string, method: string, filters?: OperationFilters, stats?: FilterStatistics): boolean;
|
|
471
|
-
/**
|
|
472
|
-
* Validate filter statistics and emit warnings for filters that matched nothing
|
|
473
|
-
* Helps users debug filter configurations that might be too restrictive or contain typos
|
|
474
|
-
*
|
|
475
|
-
* @param stats - Filter statistics object
|
|
476
|
-
* @param filters - The filter configuration to validate
|
|
477
|
-
*/
|
|
478
|
-
declare function validateFilters(stats: FilterStatistics, filters?: OperationFilters): void;
|
|
479
|
-
/**
|
|
480
|
-
* Format filter statistics for display in generated output
|
|
481
|
-
* Returns a formatted string suitable for inclusion in comments
|
|
482
|
-
*
|
|
483
|
-
* @param stats - Filter statistics object
|
|
484
|
-
* @returns Formatted statistics string
|
|
485
|
-
*/
|
|
486
|
-
declare function formatFilterStatistics(stats: FilterStatistics): string;
|
|
487
|
-
|
|
488
|
-
export { CircularReferenceError, CliOptionsError, type CommonSchemaOptions, type ConfigFile, ConfigValidationError, type ExecutionMode, FileOperationError, type FilterStatistics, GeneratorError, type OpenAPISchema, type OpenAPISpec, OpenApiGenerator, type OpenApiGeneratorOptions, type OperationFilters, type RequestOptions, type ResponseOptions, SchemaGenerationError, SpecValidationError, createFilterStatistics, defineConfig, formatFilterStatistics, shouldIncludeOperation, validateFilters };
|
|
153
|
+
export { CircularReferenceError, CliOptionsError, ConfigValidationError, FileOperationError, GeneratorError, OpenApiGenerator, OpenApiGeneratorOptions, SchemaGenerationError, SpecValidationError };
|
package/dist/index.js
CHANGED
|
@@ -28,11 +28,7 @@ __export(src_exports, {
|
|
|
28
28
|
OpenApiGenerator: () => OpenApiGenerator,
|
|
29
29
|
SchemaGenerationError: () => SchemaGenerationError,
|
|
30
30
|
SpecValidationError: () => SpecValidationError,
|
|
31
|
-
|
|
32
|
-
defineConfig: () => defineConfig,
|
|
33
|
-
formatFilterStatistics: () => formatFilterStatistics,
|
|
34
|
-
shouldIncludeOperation: () => shouldIncludeOperation,
|
|
35
|
-
validateFilters: () => validateFilters
|
|
31
|
+
defineConfig: () => defineConfig
|
|
36
32
|
});
|
|
37
33
|
module.exports = __toCommonJS(src_exports);
|
|
38
34
|
|
|
@@ -98,6 +94,7 @@ var ConfigurationError = class extends GeneratorError {
|
|
|
98
94
|
// src/openapi-generator.ts
|
|
99
95
|
var import_node_fs = require("fs");
|
|
100
96
|
var import_node_path = require("path");
|
|
97
|
+
var import_minimatch2 = require("minimatch");
|
|
101
98
|
var import_yaml = require("yaml");
|
|
102
99
|
|
|
103
100
|
// src/utils/name-utils.ts
|
|
@@ -234,6 +231,9 @@ var LRUCache = class {
|
|
|
234
231
|
this.cache = /* @__PURE__ */ new Map();
|
|
235
232
|
this.maxSize = maxSize;
|
|
236
233
|
}
|
|
234
|
+
get capacity() {
|
|
235
|
+
return this.maxSize;
|
|
236
|
+
}
|
|
237
237
|
get(key) {
|
|
238
238
|
if (!this.cache.has(key)) return void 0;
|
|
239
239
|
const value = this.cache.get(key);
|
|
@@ -783,6 +783,11 @@ ${properties.join(",\n")}
|
|
|
783
783
|
|
|
784
784
|
// src/validators/string-validator.ts
|
|
785
785
|
var PATTERN_CACHE = new LRUCache(1e3);
|
|
786
|
+
function configurePatternCache(size) {
|
|
787
|
+
if (size > 0 && size !== PATTERN_CACHE.capacity) {
|
|
788
|
+
PATTERN_CACHE = new LRUCache(size);
|
|
789
|
+
}
|
|
790
|
+
}
|
|
786
791
|
var FORMAT_MAP = {
|
|
787
792
|
uuid: "z.uuid()",
|
|
788
793
|
email: "z.email()",
|
|
@@ -1403,7 +1408,7 @@ var OpenApiGenerator = class {
|
|
|
1403
1408
|
this.schemaUsageMap = /* @__PURE__ */ new Map();
|
|
1404
1409
|
this.needsZodImport = true;
|
|
1405
1410
|
this.filterStats = createFilterStatistics();
|
|
1406
|
-
var _a, _b, _c;
|
|
1411
|
+
var _a, _b, _c, _d, _e;
|
|
1407
1412
|
if (!options.input) {
|
|
1408
1413
|
throw new ConfigurationError("Input path is required", { providedOptions: options });
|
|
1409
1414
|
}
|
|
@@ -1419,8 +1424,14 @@ var OpenApiGenerator = class {
|
|
|
1419
1424
|
showStats: (_c = options.showStats) != null ? _c : true,
|
|
1420
1425
|
request: options.request,
|
|
1421
1426
|
response: options.response,
|
|
1422
|
-
operationFilters: options.operationFilters
|
|
1427
|
+
operationFilters: options.operationFilters,
|
|
1428
|
+
ignoreHeaders: options.ignoreHeaders,
|
|
1429
|
+
cacheSize: (_d = options.cacheSize) != null ? _d : 1e3,
|
|
1430
|
+
batchSize: (_e = options.batchSize) != null ? _e : 10
|
|
1423
1431
|
};
|
|
1432
|
+
if (this.options.cacheSize) {
|
|
1433
|
+
configurePatternCache(this.options.cacheSize);
|
|
1434
|
+
}
|
|
1424
1435
|
try {
|
|
1425
1436
|
const fs = require("fs");
|
|
1426
1437
|
if (!fs.existsSync(this.options.input)) {
|
|
@@ -1556,6 +1567,7 @@ var OpenApiGenerator = class {
|
|
|
1556
1567
|
const normalizedOutput = (0, import_node_path.normalize)(this.options.output);
|
|
1557
1568
|
this.ensureDirectoryExists(normalizedOutput);
|
|
1558
1569
|
(0, import_node_fs.writeFileSync)(normalizedOutput, output);
|
|
1570
|
+
console.log(` \u2713 Generated ${normalizedOutput}`);
|
|
1559
1571
|
}
|
|
1560
1572
|
/**
|
|
1561
1573
|
* Resolve options for a specific context (request or response)
|
|
@@ -1966,6 +1978,24 @@ ${propsCode}
|
|
|
1966
1978
|
}
|
|
1967
1979
|
}
|
|
1968
1980
|
}
|
|
1981
|
+
/**
|
|
1982
|
+
* Check if a header should be ignored based on filter patterns
|
|
1983
|
+
* @internal
|
|
1984
|
+
*/
|
|
1985
|
+
shouldIgnoreHeader(headerName) {
|
|
1986
|
+
const ignorePatterns = this.options.ignoreHeaders;
|
|
1987
|
+
if (!ignorePatterns || ignorePatterns.length === 0) {
|
|
1988
|
+
return false;
|
|
1989
|
+
}
|
|
1990
|
+
if (ignorePatterns.includes("*")) {
|
|
1991
|
+
return true;
|
|
1992
|
+
}
|
|
1993
|
+
const headerLower = headerName.toLowerCase();
|
|
1994
|
+
return ignorePatterns.some((pattern) => {
|
|
1995
|
+
const patternLower = pattern.toLowerCase();
|
|
1996
|
+
return (0, import_minimatch2.minimatch)(headerLower, patternLower);
|
|
1997
|
+
});
|
|
1998
|
+
}
|
|
1969
1999
|
/**
|
|
1970
2000
|
* Generate header parameter schemas for each operation
|
|
1971
2001
|
* Header parameters are always string type (HTTP header semantics)
|
|
@@ -1988,7 +2018,7 @@ ${propsCode}
|
|
|
1988
2018
|
continue;
|
|
1989
2019
|
}
|
|
1990
2020
|
const headerParams = operation.parameters.filter(
|
|
1991
|
-
(param) => param && typeof param === "object" && param.in === "header"
|
|
2021
|
+
(param) => param && typeof param === "object" && param.in === "header" && !this.shouldIgnoreHeader(param.name)
|
|
1992
2022
|
);
|
|
1993
2023
|
if (headerParams.length === 0) {
|
|
1994
2024
|
continue;
|
|
@@ -2199,10 +2229,6 @@ function defineConfig(config) {
|
|
|
2199
2229
|
OpenApiGenerator,
|
|
2200
2230
|
SchemaGenerationError,
|
|
2201
2231
|
SpecValidationError,
|
|
2202
|
-
|
|
2203
|
-
defineConfig,
|
|
2204
|
-
formatFilterStatistics,
|
|
2205
|
-
shouldIncludeOperation,
|
|
2206
|
-
validateFilters
|
|
2232
|
+
defineConfig
|
|
2207
2233
|
});
|
|
2208
2234
|
//# sourceMappingURL=index.js.map
|