next-openapi-gen 1.2.3 → 1.4.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 +36 -33
- package/dist/cli.js +319 -143
- package/dist/index.js +319 -143
- package/dist/next/index.js +204 -28
- package/dist/react-router/index.js +204 -28
- package/dist/vite/index.js +204 -28
- package/package.json +1 -1
package/dist/next/index.js
CHANGED
|
@@ -938,7 +938,7 @@ function parseJSDocBlock(commentValue, filePath) {
|
|
|
938
938
|
result.cookieType = extractTypeFromComment(normalizedComment, "@cookie");
|
|
939
939
|
const authValue = extractLineValue(normalizedComment, "@auth");
|
|
940
940
|
if (authValue) {
|
|
941
|
-
result.auth =
|
|
941
|
+
result.auth = authValue;
|
|
942
942
|
}
|
|
943
943
|
const querystring = parseQuerystringTag(normalizedComment);
|
|
944
944
|
if (querystring) {
|
|
@@ -1306,6 +1306,17 @@ function mergeJSDocData(target, source) {
|
|
|
1306
1306
|
function cleanComment(commentValue) {
|
|
1307
1307
|
return commentValue.replace(/\*\s*/g, "").trim();
|
|
1308
1308
|
}
|
|
1309
|
+
function extractInternalFlagFromComments(comments) {
|
|
1310
|
+
if (!comments)
|
|
1311
|
+
return false;
|
|
1312
|
+
for (const comment of comments) {
|
|
1313
|
+
const cleaned = cleanComment(comment.value);
|
|
1314
|
+
if (/@internal\b/.test(cleaned) || /@schema\s+false\b/.test(cleaned)) {
|
|
1315
|
+
return true;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
return false;
|
|
1319
|
+
}
|
|
1309
1320
|
function extractSchemaIdFromComments(comments) {
|
|
1310
1321
|
if (!comments)
|
|
1311
1322
|
return null;
|
|
@@ -1602,16 +1613,18 @@ var INTERNAL_OPENAPI_CONFIG_KEYS = [
|
|
|
1602
1613
|
"framework",
|
|
1603
1614
|
"next",
|
|
1604
1615
|
"diagnostics",
|
|
1605
|
-
"debug"
|
|
1616
|
+
"debug",
|
|
1617
|
+
"authPresets",
|
|
1618
|
+
"excludeSchemas"
|
|
1606
1619
|
];
|
|
1607
|
-
var
|
|
1620
|
+
var DEFAULT_AUTH_PRESET_REPLACEMENTS = {
|
|
1608
1621
|
bearer: "BearerAuth",
|
|
1609
1622
|
basic: "BasicAuth",
|
|
1610
1623
|
apikey: "ApiKeyAuth"
|
|
1611
1624
|
};
|
|
1612
|
-
function performAuthPresetReplacements(authValue) {
|
|
1625
|
+
function performAuthPresetReplacements(authValue, presets = DEFAULT_AUTH_PRESET_REPLACEMENTS) {
|
|
1613
1626
|
const authParts = authValue.split(",").map((part) => part.trim());
|
|
1614
|
-
const mappedParts = authParts.map((part) =>
|
|
1627
|
+
const mappedParts = authParts.map((part) => presets[part.toLowerCase()] || part);
|
|
1615
1628
|
return mappedParts.join(",");
|
|
1616
1629
|
}
|
|
1617
1630
|
function getOperationId(routePath, method) {
|
|
@@ -2316,6 +2329,7 @@ function normalizeOpenApiConfig(template) {
|
|
|
2316
2329
|
outputDir: template.outputDir ?? DEFAULT_OUTPUT_DIR,
|
|
2317
2330
|
includeOpenApiRoutes: template.includeOpenApiRoutes ?? DEFAULT_INCLUDE_OPENAPI_ROUTES,
|
|
2318
2331
|
ignoreRoutes: template.ignoreRoutes ?? [],
|
|
2332
|
+
excludeSchemas: template.excludeSchemas ?? [],
|
|
2319
2333
|
schemaType: template.schemaType ?? DEFAULT_RUNTIME_SCHEMA_TYPE,
|
|
2320
2334
|
schemaBackends,
|
|
2321
2335
|
schemaFiles: template.schemaFiles ?? [],
|
|
@@ -2329,6 +2343,7 @@ function normalizeOpenApiConfig(template) {
|
|
|
2329
2343
|
adapterPath: template.next?.adapterPath
|
|
2330
2344
|
},
|
|
2331
2345
|
diagnostics: template.diagnostics ?? { enabled: DEFAULT_DIAGNOSTICS_ENABLED },
|
|
2346
|
+
authPresets: { ...DEFAULT_AUTH_PRESET_REPLACEMENTS, ...template.authPresets },
|
|
2332
2347
|
debug: template.debug ?? DEFAULT_DEBUG
|
|
2333
2348
|
};
|
|
2334
2349
|
}
|
|
@@ -2810,8 +2825,10 @@ function downgradeSchemaForOpenApi30(schema, mediaTypeName) {
|
|
|
2810
2825
|
const nullableBranch = nextSchema.anyOf.find((item) => item.type === "null");
|
|
2811
2826
|
const baseBranch = nextSchema.anyOf.find((item) => item.type !== "null");
|
|
2812
2827
|
if (nullableBranch && baseBranch) {
|
|
2828
|
+
const { anyOf: _anyOf, ...outerMeta } = nextSchema;
|
|
2813
2829
|
nextSchema = {
|
|
2814
2830
|
...structuredClone(baseBranch),
|
|
2831
|
+
...outerMeta,
|
|
2815
2832
|
nullable: true
|
|
2816
2833
|
};
|
|
2817
2834
|
}
|
|
@@ -4686,7 +4703,7 @@ function processZodLiteral(node, context) {
|
|
|
4686
4703
|
return { type: "string", enum: [arg.value] };
|
|
4687
4704
|
}
|
|
4688
4705
|
if (t9.isNumericLiteral(arg)) {
|
|
4689
|
-
return { type: "number", enum: [arg.value] };
|
|
4706
|
+
return { type: Number.isInteger(arg.value) ? "integer" : "number", enum: [arg.value] };
|
|
4690
4707
|
}
|
|
4691
4708
|
if (t9.isBooleanLiteral(arg)) {
|
|
4692
4709
|
return { type: "boolean", enum: [arg.value] };
|
|
@@ -4702,7 +4719,7 @@ function processZodLiteral(node, context) {
|
|
|
4702
4719
|
if (typeof value === "string")
|
|
4703
4720
|
return { type: "string", enum: [value] };
|
|
4704
4721
|
if (typeof value === "number")
|
|
4705
|
-
return { type: "number", enum: [value] };
|
|
4722
|
+
return { type: Number.isInteger(value) ? "integer" : "number", enum: [value] };
|
|
4706
4723
|
if (typeof value === "boolean")
|
|
4707
4724
|
return { type: "boolean", enum: [value] };
|
|
4708
4725
|
if (value === null)
|
|
@@ -4797,7 +4814,7 @@ function processZodTuple(node, processNode, context) {
|
|
|
4797
4814
|
if (t9.isIdentifier(node.arguments[0]) && context?.resolveConstArrayValues) {
|
|
4798
4815
|
const values = context.resolveConstArrayValues(node.arguments[0].name);
|
|
4799
4816
|
if (values && values.length > 0) {
|
|
4800
|
-
const prefixItems = values.map((value) => typeof value === "number" ? { type: "number", enum: [value] } : { type: "string", enum: [value] });
|
|
4817
|
+
const prefixItems = values.map((value) => typeof value === "number" ? { type: Number.isInteger(value) ? "integer" : "number", enum: [value] } : { type: "string", enum: [value] });
|
|
4801
4818
|
return {
|
|
4802
4819
|
type: "array",
|
|
4803
4820
|
prefixItems,
|
|
@@ -4841,7 +4858,7 @@ function processZodUnion(node, processNode, context) {
|
|
|
4841
4858
|
if (t9.isIdentifier(node.arguments[0]) && context?.resolveConstArrayValues) {
|
|
4842
4859
|
const values = context.resolveConstArrayValues(node.arguments[0].name);
|
|
4843
4860
|
if (values && values.length > 0) {
|
|
4844
|
-
const type = typeof values[0] === "number" ? "number" : "string";
|
|
4861
|
+
const type = typeof values[0] === "number" ? Number.isInteger(values[0]) ? "integer" : "number" : "string";
|
|
4845
4862
|
return { type, enum: values };
|
|
4846
4863
|
}
|
|
4847
4864
|
}
|
|
@@ -12288,8 +12305,17 @@ var ZodRuntimeExporter = class {
|
|
|
12288
12305
|
return node.arguments[0] ? literal(this.buildLiteralValue(node.arguments[0])) : null;
|
|
12289
12306
|
case "enum":
|
|
12290
12307
|
return this.buildEnum(node);
|
|
12291
|
-
case "array":
|
|
12292
|
-
|
|
12308
|
+
case "array": {
|
|
12309
|
+
const arg = node.arguments[0];
|
|
12310
|
+
if (!arg || !isProcessableNode(arg)) {
|
|
12311
|
+
return array(unknown());
|
|
12312
|
+
}
|
|
12313
|
+
const itemSchema = this.buildSchema(arg);
|
|
12314
|
+
if (!itemSchema) {
|
|
12315
|
+
return null;
|
|
12316
|
+
}
|
|
12317
|
+
return array(itemSchema);
|
|
12318
|
+
}
|
|
12293
12319
|
case "strictObject": {
|
|
12294
12320
|
const base = this.buildObject(node);
|
|
12295
12321
|
return base && typeof base.strict === "function" ? base.strict() : base;
|
|
@@ -12421,13 +12447,17 @@ var ZodRuntimeExporter = class {
|
|
|
12421
12447
|
if (node.arguments.length === 0 || !t10.isArrayExpression(node.arguments[0])) {
|
|
12422
12448
|
return tuple([]);
|
|
12423
12449
|
}
|
|
12424
|
-
const items =
|
|
12450
|
+
const items = [];
|
|
12451
|
+
for (const element of node.arguments[0].elements) {
|
|
12425
12452
|
if (!isProcessableNode(element)) {
|
|
12426
|
-
return
|
|
12453
|
+
return null;
|
|
12427
12454
|
}
|
|
12428
12455
|
const schema = this.buildSchema(element);
|
|
12429
|
-
|
|
12430
|
-
|
|
12456
|
+
if (!schema) {
|
|
12457
|
+
return null;
|
|
12458
|
+
}
|
|
12459
|
+
items.push(schema);
|
|
12460
|
+
}
|
|
12431
12461
|
return tuple(items);
|
|
12432
12462
|
}
|
|
12433
12463
|
buildTemplateLiteral(node) {
|
|
@@ -12728,6 +12758,8 @@ var ZodSchemaConverter = class {
|
|
|
12728
12758
|
/** Schema variable names whose component name was overridden via .meta({ id }). These must
|
|
12729
12759
|
* NOT be copied back under the original variable name in the OpenAPI components object. */
|
|
12730
12760
|
metaIdSchemaNames = /* @__PURE__ */ new Set();
|
|
12761
|
+
/** Schema variable names marked @internal — excluded from components/schemas output. */
|
|
12762
|
+
internalSchemaNames = /* @__PURE__ */ new Set();
|
|
12731
12763
|
// Current processing context (set during file processing)
|
|
12732
12764
|
currentFilePath;
|
|
12733
12765
|
currentAST;
|
|
@@ -13037,7 +13069,12 @@ var ZodSchemaConverter = class {
|
|
|
13037
13069
|
if (this.isZodSchema(path19.node.init)) {
|
|
13038
13070
|
const schema = this.processZodNode(path19.node.init);
|
|
13039
13071
|
if (schema) {
|
|
13040
|
-
this.
|
|
13072
|
+
const overrideId = this.extractMetaIdFromNode(path19.node.init);
|
|
13073
|
+
if (overrideId) {
|
|
13074
|
+
this.applyMetaIdOverride(schemaName, schema, overrideId, filePath);
|
|
13075
|
+
} else {
|
|
13076
|
+
this.storeResolvedSchema(schemaName, schema);
|
|
13077
|
+
}
|
|
13041
13078
|
}
|
|
13042
13079
|
return;
|
|
13043
13080
|
}
|
|
@@ -13380,8 +13417,15 @@ var ZodSchemaConverter = class {
|
|
|
13380
13417
|
};
|
|
13381
13418
|
switch (methodName) {
|
|
13382
13419
|
case "optional":
|
|
13420
|
+
break;
|
|
13383
13421
|
case "nullable":
|
|
13384
13422
|
case "nullish":
|
|
13423
|
+
schema = {
|
|
13424
|
+
anyOf: [
|
|
13425
|
+
{ $ref: `#/components/schemas/${this.getSchemaReferenceName(schemaName)}` },
|
|
13426
|
+
{ type: "null" }
|
|
13427
|
+
]
|
|
13428
|
+
};
|
|
13385
13429
|
break;
|
|
13386
13430
|
case "describe":
|
|
13387
13431
|
if (node.arguments.length > 0 && t11.isStringLiteral(node.arguments[0])) {
|
|
@@ -13899,12 +13943,16 @@ var ZodSchemaConverter = class {
|
|
|
13899
13943
|
case "optional":
|
|
13900
13944
|
break;
|
|
13901
13945
|
case "nullable":
|
|
13902
|
-
if (
|
|
13946
|
+
if (schema.allOf) {
|
|
13947
|
+
schema = { anyOf: [...schema.allOf, { type: "null" }] };
|
|
13948
|
+
} else {
|
|
13903
13949
|
schema.nullable = true;
|
|
13904
13950
|
}
|
|
13905
13951
|
break;
|
|
13906
13952
|
case "nullish":
|
|
13907
|
-
if (
|
|
13953
|
+
if (schema.allOf) {
|
|
13954
|
+
schema = { anyOf: [...schema.allOf, { type: "null" }] };
|
|
13955
|
+
} else {
|
|
13908
13956
|
schema.nullable = true;
|
|
13909
13957
|
}
|
|
13910
13958
|
break;
|
|
@@ -14349,7 +14397,13 @@ var ZodSchemaConverter = class {
|
|
|
14349
14397
|
* Get all processed Zod schemas
|
|
14350
14398
|
*/
|
|
14351
14399
|
getProcessedSchemas() {
|
|
14352
|
-
|
|
14400
|
+
const result = {};
|
|
14401
|
+
for (const [name, schema] of Object.entries(this.zodSchemas)) {
|
|
14402
|
+
if (!this.internalSchemaNames.has(name)) {
|
|
14403
|
+
result[name] = schema;
|
|
14404
|
+
}
|
|
14405
|
+
}
|
|
14406
|
+
return result;
|
|
14353
14407
|
}
|
|
14354
14408
|
/**
|
|
14355
14409
|
* Pre-scan all files to build type mappings
|
|
@@ -14401,9 +14455,21 @@ var ZodSchemaConverter = class {
|
|
|
14401
14455
|
if (t11.isIdentifier(declaration.id) && declaration.init) {
|
|
14402
14456
|
const schemaName = declaration.id.name;
|
|
14403
14457
|
if (this.isZodSchema(declaration.init)) {
|
|
14458
|
+
const decl = path19.node.declaration;
|
|
14459
|
+
const allComments = [
|
|
14460
|
+
...path19.node.leadingComments ?? [],
|
|
14461
|
+
...decl?.leadingComments ?? [],
|
|
14462
|
+
...declaration.leadingComments ?? []
|
|
14463
|
+
];
|
|
14464
|
+
if (extractInternalFlagFromComments(allComments)) {
|
|
14465
|
+
this.internalSchemaNames.add(schemaName);
|
|
14466
|
+
}
|
|
14404
14467
|
if (!this.getStoredSchema(schemaName)) {
|
|
14405
14468
|
logger.debug(`Pre-processing Zod schema: ${schemaName}`);
|
|
14406
14469
|
this.processingSchemas.add(schemaName);
|
|
14470
|
+
this.currentFilePath = filePath;
|
|
14471
|
+
this.currentAST = ast;
|
|
14472
|
+
this.currentImports = importedModules;
|
|
14407
14473
|
const schema = this.processZodNode(declaration.init);
|
|
14408
14474
|
this.processingSchemas.delete(schemaName);
|
|
14409
14475
|
if (schema) {
|
|
@@ -14426,9 +14492,19 @@ var ZodSchemaConverter = class {
|
|
|
14426
14492
|
if (t11.isIdentifier(declaration.id) && declaration.init) {
|
|
14427
14493
|
const schemaName = declaration.id.name;
|
|
14428
14494
|
if (this.isZodSchema(declaration.init)) {
|
|
14495
|
+
const allComments = [
|
|
14496
|
+
...path19.node.leadingComments ?? [],
|
|
14497
|
+
...declaration.leadingComments ?? []
|
|
14498
|
+
];
|
|
14499
|
+
if (extractInternalFlagFromComments(allComments)) {
|
|
14500
|
+
this.internalSchemaNames.add(schemaName);
|
|
14501
|
+
}
|
|
14429
14502
|
if (!this.getStoredSchema(schemaName) && !this.processingSchemas.has(schemaName)) {
|
|
14430
14503
|
logger.debug(`Pre-processing Zod schema: ${schemaName}`);
|
|
14431
14504
|
this.processingSchemas.add(schemaName);
|
|
14505
|
+
this.currentFilePath = filePath;
|
|
14506
|
+
this.currentAST = ast;
|
|
14507
|
+
this.currentImports = importedModules;
|
|
14432
14508
|
const schema = this.processZodNode(declaration.init);
|
|
14433
14509
|
this.processingSchemas.delete(schemaName);
|
|
14434
14510
|
if (schema) {
|
|
@@ -15160,7 +15236,7 @@ function collectFirstMemberLeadingComments(interfaceDecl) {
|
|
|
15160
15236
|
const firstMember = body.body?.[0];
|
|
15161
15237
|
return firstMember?.leadingComments ?? [];
|
|
15162
15238
|
}
|
|
15163
|
-
function collectAllExportedDefinitions(ast, typeDefinitions, currentFile, schemaIdAliases) {
|
|
15239
|
+
function collectAllExportedDefinitions(ast, typeDefinitions, currentFile, schemaIdAliases, internalSchemaNames) {
|
|
15164
15240
|
function registerDefinition(name, entry, allComments) {
|
|
15165
15241
|
if (!typeDefinitions[name]) {
|
|
15166
15242
|
typeDefinitions[name] = entry;
|
|
@@ -15172,6 +15248,9 @@ function collectAllExportedDefinitions(ast, typeDefinitions, currentFile, schema
|
|
|
15172
15248
|
typeDefinitions[overrideId] = entry;
|
|
15173
15249
|
}
|
|
15174
15250
|
}
|
|
15251
|
+
if (internalSchemaNames && extractInternalFlagFromComments(allComments)) {
|
|
15252
|
+
internalSchemaNames.add(name);
|
|
15253
|
+
}
|
|
15175
15254
|
}
|
|
15176
15255
|
resolvedTraverse(ast, {
|
|
15177
15256
|
TSTypeAliasDeclaration: (path19) => {
|
|
@@ -15651,6 +15730,7 @@ var SchemaProcessor = class {
|
|
|
15651
15730
|
schemaTypes;
|
|
15652
15731
|
isResolvingPickOmitBase = false;
|
|
15653
15732
|
schemaIdAliases = {};
|
|
15733
|
+
internalSchemaNames = /* @__PURE__ */ new Set();
|
|
15654
15734
|
fileAccess;
|
|
15655
15735
|
symbolResolver;
|
|
15656
15736
|
// Track imports per file for resolving ReturnType<typeof func>
|
|
@@ -15691,7 +15771,7 @@ var SchemaProcessor = class {
|
|
|
15691
15771
|
getDefinedSchemas() {
|
|
15692
15772
|
const filteredSchemas = {};
|
|
15693
15773
|
Object.entries(this.openapiDefinitions).forEach(([key, value]) => {
|
|
15694
|
-
if (!this.schemaIdAliases[key] && !this.isGenericTypeParameter(key) && !this.isInvalidSchemaName(key) && !this.isBuiltInUtilityType(key) && !this.isFunctionSchema(key)) {
|
|
15774
|
+
if (!this.schemaIdAliases[key] && !this.isGenericTypeParameter(key) && !this.isInvalidSchemaName(key) && !this.isBuiltInUtilityType(key) && !this.isFunctionSchema(key) && !this.internalSchemaNames.has(key)) {
|
|
15695
15775
|
filteredSchemas[key] = value;
|
|
15696
15776
|
}
|
|
15697
15777
|
});
|
|
@@ -15701,6 +15781,22 @@ var SchemaProcessor = class {
|
|
|
15701
15781
|
this.customSchemaProcessor.getDefinedSchemas()
|
|
15702
15782
|
]);
|
|
15703
15783
|
}
|
|
15784
|
+
getInternalSchemas() {
|
|
15785
|
+
const result = {};
|
|
15786
|
+
for (const name of this.internalSchemaNames) {
|
|
15787
|
+
const def = this.openapiDefinitions[name];
|
|
15788
|
+
if (def)
|
|
15789
|
+
result[name] = def;
|
|
15790
|
+
}
|
|
15791
|
+
if (this.zodSchemaConverter) {
|
|
15792
|
+
for (const name of this.zodSchemaConverter.internalSchemaNames) {
|
|
15793
|
+
const schema = this.zodSchemaConverter.zodSchemas[name];
|
|
15794
|
+
if (schema)
|
|
15795
|
+
result[name] = schema;
|
|
15796
|
+
}
|
|
15797
|
+
}
|
|
15798
|
+
return result;
|
|
15799
|
+
}
|
|
15704
15800
|
findSchemaDefinition(schemaName, contentType) {
|
|
15705
15801
|
this.contentType = contentType;
|
|
15706
15802
|
if (schemaName.includes("<") && schemaName.includes(">")) {
|
|
@@ -15851,7 +15947,7 @@ var SchemaProcessor = class {
|
|
|
15851
15947
|
* Used when processing imported files to ensure all referenced types are available
|
|
15852
15948
|
*/
|
|
15853
15949
|
collectAllExportedDefinitions(ast, filePath) {
|
|
15854
|
-
collectAllExportedDefinitions(ast, this.typeDefinitions, filePath || this.currentFilePath, this.schemaIdAliases);
|
|
15950
|
+
collectAllExportedDefinitions(ast, this.typeDefinitions, filePath || this.currentFilePath, this.schemaIdAliases, this.internalSchemaNames);
|
|
15855
15951
|
}
|
|
15856
15952
|
collectTypeDefinitions(ast, schemaName, filePath) {
|
|
15857
15953
|
collectTypeDefinitions(ast, schemaName, this.typeDefinitions, filePath || this.currentFilePath);
|
|
@@ -17279,11 +17375,16 @@ var ResponseProcessor = class {
|
|
|
17279
17375
|
var OperationProcessor = class {
|
|
17280
17376
|
schemaProcessor;
|
|
17281
17377
|
responseProcessor;
|
|
17378
|
+
authPresets;
|
|
17282
17379
|
performanceProfile;
|
|
17283
|
-
constructor(schemaProcessor, responseProcessor,
|
|
17380
|
+
constructor(schemaProcessor, responseProcessor, options = {}) {
|
|
17284
17381
|
this.schemaProcessor = schemaProcessor;
|
|
17285
17382
|
this.responseProcessor = responseProcessor;
|
|
17286
|
-
this.
|
|
17383
|
+
this.authPresets = {
|
|
17384
|
+
...DEFAULT_AUTH_PRESET_REPLACEMENTS,
|
|
17385
|
+
...options.authPresets
|
|
17386
|
+
};
|
|
17387
|
+
this.performanceProfile = options.performanceProfile;
|
|
17287
17388
|
}
|
|
17288
17389
|
processOperation(varName, routePath, dataTypes, pathParamNames = []) {
|
|
17289
17390
|
const method = varName.toLowerCase();
|
|
@@ -17308,9 +17409,10 @@ var OperationProcessor = class {
|
|
|
17308
17409
|
definition.deprecated = true;
|
|
17309
17410
|
}
|
|
17310
17411
|
if (explicitSecurity && explicitSecurity.length > 0) {
|
|
17311
|
-
definition.security = explicitSecurity;
|
|
17412
|
+
definition.security = explicitSecurity.map((req) => Object.fromEntries(Object.entries(req).map(([scheme, scopes]) => [this.applyPreset(scheme), scopes])));
|
|
17312
17413
|
} else if (auth) {
|
|
17313
|
-
const
|
|
17414
|
+
const mapped = performAuthPresetReplacements(auth, this.authPresets);
|
|
17415
|
+
const authItems = mapped.split(",").map((item) => item.trim());
|
|
17314
17416
|
definition.security = authItems.map((authItem) => ({
|
|
17315
17417
|
[authItem]: []
|
|
17316
17418
|
}));
|
|
@@ -17523,6 +17625,9 @@ ${suffix}`;
|
|
|
17523
17625
|
response.links[link.name] = linkObject;
|
|
17524
17626
|
}
|
|
17525
17627
|
}
|
|
17628
|
+
applyPreset(scheme) {
|
|
17629
|
+
return this.authPresets[scheme.toLowerCase()] ?? scheme;
|
|
17630
|
+
}
|
|
17526
17631
|
createQuerystringParameter(dataTypes) {
|
|
17527
17632
|
if (!dataTypes.querystringType) {
|
|
17528
17633
|
return void 0;
|
|
@@ -17611,7 +17716,10 @@ var RouteProcessor = class {
|
|
|
17611
17716
|
return new RegExp(`^${regexPattern}$`);
|
|
17612
17717
|
});
|
|
17613
17718
|
this.responseProcessor = new ResponseProcessor(this.config, this.schemaProcessor);
|
|
17614
|
-
this.operationProcessor = new OperationProcessor(this.schemaProcessor, this.responseProcessor,
|
|
17719
|
+
this.operationProcessor = new OperationProcessor(this.schemaProcessor, this.responseProcessor, {
|
|
17720
|
+
authPresets: this.config.authPresets,
|
|
17721
|
+
performanceProfile: this.performanceProfile
|
|
17722
|
+
});
|
|
17615
17723
|
}
|
|
17616
17724
|
processResponsesFromConfig(dataTypes, method) {
|
|
17617
17725
|
return this.responseProcessor.processResponses(dataTypes, method);
|
|
@@ -17837,6 +17945,64 @@ function generateErrorResponsesFromConfig(document, errorConfig) {
|
|
|
17837
17945
|
});
|
|
17838
17946
|
}
|
|
17839
17947
|
|
|
17948
|
+
// ../openapi-core/dist/core/exclude-schemas.js
|
|
17949
|
+
function patternToRegExp(pattern) {
|
|
17950
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
17951
|
+
return new RegExp(`^${escaped.replace(/\*/g, ".*")}$`);
|
|
17952
|
+
}
|
|
17953
|
+
function matchExcludePatterns(names, patterns) {
|
|
17954
|
+
if (patterns.length === 0)
|
|
17955
|
+
return [];
|
|
17956
|
+
const regexes = patterns.map(patternToRegExp);
|
|
17957
|
+
return names.filter((name) => regexes.some((re) => re.test(name)));
|
|
17958
|
+
}
|
|
17959
|
+
function applyExcludeSchemas(document, mergedSchemas, excludedSchemas) {
|
|
17960
|
+
const excludedNames = new Set(Object.keys(excludedSchemas));
|
|
17961
|
+
if (excludedNames.size === 0)
|
|
17962
|
+
return;
|
|
17963
|
+
walkAndInline(document, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
17964
|
+
for (const name of excludedNames) {
|
|
17965
|
+
delete mergedSchemas[name];
|
|
17966
|
+
}
|
|
17967
|
+
}
|
|
17968
|
+
function walkAndInline(obj, excluded, excludedNames, visiting) {
|
|
17969
|
+
if (!obj || typeof obj !== "object")
|
|
17970
|
+
return;
|
|
17971
|
+
if (Array.isArray(obj)) {
|
|
17972
|
+
for (const item of obj) {
|
|
17973
|
+
walkAndInline(item, excluded, excludedNames, visiting);
|
|
17974
|
+
}
|
|
17975
|
+
return;
|
|
17976
|
+
}
|
|
17977
|
+
const rec = obj;
|
|
17978
|
+
const ref = rec["$ref"];
|
|
17979
|
+
if (typeof ref === "string") {
|
|
17980
|
+
const match = ref.match(/^#\/components\/schemas\/(.+)$/);
|
|
17981
|
+
const name = match?.[1];
|
|
17982
|
+
if (name && excludedNames.has(name)) {
|
|
17983
|
+
if (visiting.has(name)) {
|
|
17984
|
+
logger.warn(`Circular reference to internal schema "${name}", keeping $ref`);
|
|
17985
|
+
return;
|
|
17986
|
+
}
|
|
17987
|
+
const schemaDef = excluded[name];
|
|
17988
|
+
if (schemaDef) {
|
|
17989
|
+
const cloned = JSON.parse(JSON.stringify(schemaDef));
|
|
17990
|
+
delete rec["$ref"];
|
|
17991
|
+
Object.assign(rec, cloned);
|
|
17992
|
+
const newVisiting = new Set(visiting);
|
|
17993
|
+
newVisiting.add(name);
|
|
17994
|
+
for (const key of Object.keys(rec)) {
|
|
17995
|
+
walkAndInline(rec[key], excluded, excludedNames, newVisiting);
|
|
17996
|
+
}
|
|
17997
|
+
return;
|
|
17998
|
+
}
|
|
17999
|
+
}
|
|
18000
|
+
}
|
|
18001
|
+
for (const key of Object.keys(rec)) {
|
|
18002
|
+
walkAndInline(rec[key], excluded, excludedNames, visiting);
|
|
18003
|
+
}
|
|
18004
|
+
}
|
|
18005
|
+
|
|
17840
18006
|
// ../openapi-core/dist/core/orchestrator.js
|
|
17841
18007
|
function runGenerationOrchestrator({ config: config2, template, hooks, runtime, createFrameworkSource }) {
|
|
17842
18008
|
const diagnostics = new DiagnosticsCollector();
|
|
@@ -17907,11 +18073,21 @@ function runGenerationOrchestrator({ config: config2, template, hooks, runtime,
|
|
|
17907
18073
|
}
|
|
17908
18074
|
profile.defaultComponentsAndErrorsMs = performance.now() - phaseStartedAt;
|
|
17909
18075
|
phaseStartedAt = performance.now();
|
|
17910
|
-
const
|
|
18076
|
+
const schemaProcessor = routeProcessor.getSchemaProcessor();
|
|
18077
|
+
const definedSchemas = schemaProcessor.getDefinedSchemas();
|
|
17911
18078
|
const mergedSchemas = {
|
|
17912
18079
|
...document.components.schemas,
|
|
17913
18080
|
...definedSchemas
|
|
17914
18081
|
};
|
|
18082
|
+
const internalSchemas = schemaProcessor.getInternalSchemas();
|
|
18083
|
+
const patternExcludedNames = matchExcludePatterns(Object.keys(mergedSchemas), config2.excludeSchemas ?? []);
|
|
18084
|
+
const allExcludedSchemas = {
|
|
18085
|
+
...internalSchemas,
|
|
18086
|
+
...Object.fromEntries(patternExcludedNames.map((name) => [name, mergedSchemas[name]]))
|
|
18087
|
+
};
|
|
18088
|
+
if (Object.keys(allExcludedSchemas).length > 0) {
|
|
18089
|
+
applyExcludeSchemas(document, mergedSchemas, allExcludedSchemas);
|
|
18090
|
+
}
|
|
17915
18091
|
if (Object.keys(mergedSchemas).length > 0) {
|
|
17916
18092
|
document.components.schemas = Object.fromEntries(Object.entries(mergedSchemas).sort(([a], [b]) => a.localeCompare(b, "en", { sensitivity: "base" })));
|
|
17917
18093
|
}
|