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
|
@@ -388,7 +388,7 @@ function parseJSDocBlock(commentValue, filePath) {
|
|
|
388
388
|
result.cookieType = extractTypeFromComment(normalizedComment, "@cookie");
|
|
389
389
|
const authValue = extractLineValue(normalizedComment, "@auth");
|
|
390
390
|
if (authValue) {
|
|
391
|
-
result.auth =
|
|
391
|
+
result.auth = authValue;
|
|
392
392
|
}
|
|
393
393
|
const querystring = parseQuerystringTag(normalizedComment);
|
|
394
394
|
if (querystring) {
|
|
@@ -756,6 +756,17 @@ function mergeJSDocData(target, source) {
|
|
|
756
756
|
function cleanComment(commentValue) {
|
|
757
757
|
return commentValue.replace(/\*\s*/g, "").trim();
|
|
758
758
|
}
|
|
759
|
+
function extractInternalFlagFromComments(comments) {
|
|
760
|
+
if (!comments)
|
|
761
|
+
return false;
|
|
762
|
+
for (const comment of comments) {
|
|
763
|
+
const cleaned = cleanComment(comment.value);
|
|
764
|
+
if (/@internal\b/.test(cleaned) || /@schema\s+false\b/.test(cleaned)) {
|
|
765
|
+
return true;
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
759
770
|
function extractSchemaIdFromComments(comments) {
|
|
760
771
|
if (!comments)
|
|
761
772
|
return null;
|
|
@@ -1052,16 +1063,18 @@ var INTERNAL_OPENAPI_CONFIG_KEYS = [
|
|
|
1052
1063
|
"framework",
|
|
1053
1064
|
"next",
|
|
1054
1065
|
"diagnostics",
|
|
1055
|
-
"debug"
|
|
1066
|
+
"debug",
|
|
1067
|
+
"authPresets",
|
|
1068
|
+
"excludeSchemas"
|
|
1056
1069
|
];
|
|
1057
|
-
var
|
|
1070
|
+
var DEFAULT_AUTH_PRESET_REPLACEMENTS = {
|
|
1058
1071
|
bearer: "BearerAuth",
|
|
1059
1072
|
basic: "BasicAuth",
|
|
1060
1073
|
apikey: "ApiKeyAuth"
|
|
1061
1074
|
};
|
|
1062
|
-
function performAuthPresetReplacements(authValue) {
|
|
1075
|
+
function performAuthPresetReplacements(authValue, presets = DEFAULT_AUTH_PRESET_REPLACEMENTS) {
|
|
1063
1076
|
const authParts = authValue.split(",").map((part) => part.trim());
|
|
1064
|
-
const mappedParts = authParts.map((part) =>
|
|
1077
|
+
const mappedParts = authParts.map((part) => presets[part.toLowerCase()] || part);
|
|
1065
1078
|
return mappedParts.join(",");
|
|
1066
1079
|
}
|
|
1067
1080
|
function getOperationId(routePath, method) {
|
|
@@ -1320,6 +1333,7 @@ function normalizeOpenApiConfig(template) {
|
|
|
1320
1333
|
outputDir: template.outputDir ?? DEFAULT_OUTPUT_DIR,
|
|
1321
1334
|
includeOpenApiRoutes: template.includeOpenApiRoutes ?? DEFAULT_INCLUDE_OPENAPI_ROUTES,
|
|
1322
1335
|
ignoreRoutes: template.ignoreRoutes ?? [],
|
|
1336
|
+
excludeSchemas: template.excludeSchemas ?? [],
|
|
1323
1337
|
schemaType: template.schemaType ?? DEFAULT_RUNTIME_SCHEMA_TYPE,
|
|
1324
1338
|
schemaBackends,
|
|
1325
1339
|
schemaFiles: template.schemaFiles ?? [],
|
|
@@ -1333,6 +1347,7 @@ function normalizeOpenApiConfig(template) {
|
|
|
1333
1347
|
adapterPath: template.next?.adapterPath
|
|
1334
1348
|
},
|
|
1335
1349
|
diagnostics: template.diagnostics ?? { enabled: DEFAULT_DIAGNOSTICS_ENABLED },
|
|
1350
|
+
authPresets: { ...DEFAULT_AUTH_PRESET_REPLACEMENTS, ...template.authPresets },
|
|
1336
1351
|
debug: template.debug ?? DEFAULT_DEBUG
|
|
1337
1352
|
};
|
|
1338
1353
|
}
|
|
@@ -1814,8 +1829,10 @@ function downgradeSchemaForOpenApi30(schema, mediaTypeName) {
|
|
|
1814
1829
|
const nullableBranch = nextSchema.anyOf.find((item) => item.type === "null");
|
|
1815
1830
|
const baseBranch = nextSchema.anyOf.find((item) => item.type !== "null");
|
|
1816
1831
|
if (nullableBranch && baseBranch) {
|
|
1832
|
+
const { anyOf: _anyOf, ...outerMeta } = nextSchema;
|
|
1817
1833
|
nextSchema = {
|
|
1818
1834
|
...structuredClone(baseBranch),
|
|
1835
|
+
...outerMeta,
|
|
1819
1836
|
nullable: true
|
|
1820
1837
|
};
|
|
1821
1838
|
}
|
|
@@ -3690,7 +3707,7 @@ function processZodLiteral(node, context) {
|
|
|
3690
3707
|
return { type: "string", enum: [arg.value] };
|
|
3691
3708
|
}
|
|
3692
3709
|
if (t8.isNumericLiteral(arg)) {
|
|
3693
|
-
return { type: "number", enum: [arg.value] };
|
|
3710
|
+
return { type: Number.isInteger(arg.value) ? "integer" : "number", enum: [arg.value] };
|
|
3694
3711
|
}
|
|
3695
3712
|
if (t8.isBooleanLiteral(arg)) {
|
|
3696
3713
|
return { type: "boolean", enum: [arg.value] };
|
|
@@ -3706,7 +3723,7 @@ function processZodLiteral(node, context) {
|
|
|
3706
3723
|
if (typeof value === "string")
|
|
3707
3724
|
return { type: "string", enum: [value] };
|
|
3708
3725
|
if (typeof value === "number")
|
|
3709
|
-
return { type: "number", enum: [value] };
|
|
3726
|
+
return { type: Number.isInteger(value) ? "integer" : "number", enum: [value] };
|
|
3710
3727
|
if (typeof value === "boolean")
|
|
3711
3728
|
return { type: "boolean", enum: [value] };
|
|
3712
3729
|
if (value === null)
|
|
@@ -3801,7 +3818,7 @@ function processZodTuple(node, processNode, context) {
|
|
|
3801
3818
|
if (t8.isIdentifier(node.arguments[0]) && context?.resolveConstArrayValues) {
|
|
3802
3819
|
const values = context.resolveConstArrayValues(node.arguments[0].name);
|
|
3803
3820
|
if (values && values.length > 0) {
|
|
3804
|
-
const prefixItems = values.map((value) => typeof value === "number" ? { type: "number", enum: [value] } : { type: "string", enum: [value] });
|
|
3821
|
+
const prefixItems = values.map((value) => typeof value === "number" ? { type: Number.isInteger(value) ? "integer" : "number", enum: [value] } : { type: "string", enum: [value] });
|
|
3805
3822
|
return {
|
|
3806
3823
|
type: "array",
|
|
3807
3824
|
prefixItems,
|
|
@@ -3845,7 +3862,7 @@ function processZodUnion(node, processNode, context) {
|
|
|
3845
3862
|
if (t8.isIdentifier(node.arguments[0]) && context?.resolveConstArrayValues) {
|
|
3846
3863
|
const values = context.resolveConstArrayValues(node.arguments[0].name);
|
|
3847
3864
|
if (values && values.length > 0) {
|
|
3848
|
-
const type = typeof values[0] === "number" ? "number" : "string";
|
|
3865
|
+
const type = typeof values[0] === "number" ? Number.isInteger(values[0]) ? "integer" : "number" : "string";
|
|
3849
3866
|
return { type, enum: values };
|
|
3850
3867
|
}
|
|
3851
3868
|
}
|
|
@@ -11292,8 +11309,17 @@ var ZodRuntimeExporter = class {
|
|
|
11292
11309
|
return node.arguments[0] ? literal(this.buildLiteralValue(node.arguments[0])) : null;
|
|
11293
11310
|
case "enum":
|
|
11294
11311
|
return this.buildEnum(node);
|
|
11295
|
-
case "array":
|
|
11296
|
-
|
|
11312
|
+
case "array": {
|
|
11313
|
+
const arg = node.arguments[0];
|
|
11314
|
+
if (!arg || !isProcessableNode(arg)) {
|
|
11315
|
+
return array(unknown());
|
|
11316
|
+
}
|
|
11317
|
+
const itemSchema = this.buildSchema(arg);
|
|
11318
|
+
if (!itemSchema) {
|
|
11319
|
+
return null;
|
|
11320
|
+
}
|
|
11321
|
+
return array(itemSchema);
|
|
11322
|
+
}
|
|
11297
11323
|
case "strictObject": {
|
|
11298
11324
|
const base = this.buildObject(node);
|
|
11299
11325
|
return base && typeof base.strict === "function" ? base.strict() : base;
|
|
@@ -11425,13 +11451,17 @@ var ZodRuntimeExporter = class {
|
|
|
11425
11451
|
if (node.arguments.length === 0 || !t9.isArrayExpression(node.arguments[0])) {
|
|
11426
11452
|
return tuple([]);
|
|
11427
11453
|
}
|
|
11428
|
-
const items =
|
|
11454
|
+
const items = [];
|
|
11455
|
+
for (const element of node.arguments[0].elements) {
|
|
11429
11456
|
if (!isProcessableNode(element)) {
|
|
11430
|
-
return
|
|
11457
|
+
return null;
|
|
11431
11458
|
}
|
|
11432
11459
|
const schema = this.buildSchema(element);
|
|
11433
|
-
|
|
11434
|
-
|
|
11460
|
+
if (!schema) {
|
|
11461
|
+
return null;
|
|
11462
|
+
}
|
|
11463
|
+
items.push(schema);
|
|
11464
|
+
}
|
|
11435
11465
|
return tuple(items);
|
|
11436
11466
|
}
|
|
11437
11467
|
buildTemplateLiteral(node) {
|
|
@@ -11732,6 +11762,8 @@ var ZodSchemaConverter = class {
|
|
|
11732
11762
|
/** Schema variable names whose component name was overridden via .meta({ id }). These must
|
|
11733
11763
|
* NOT be copied back under the original variable name in the OpenAPI components object. */
|
|
11734
11764
|
metaIdSchemaNames = /* @__PURE__ */ new Set();
|
|
11765
|
+
/** Schema variable names marked @internal — excluded from components/schemas output. */
|
|
11766
|
+
internalSchemaNames = /* @__PURE__ */ new Set();
|
|
11735
11767
|
// Current processing context (set during file processing)
|
|
11736
11768
|
currentFilePath;
|
|
11737
11769
|
currentAST;
|
|
@@ -12041,7 +12073,12 @@ var ZodSchemaConverter = class {
|
|
|
12041
12073
|
if (this.isZodSchema(path17.node.init)) {
|
|
12042
12074
|
const schema = this.processZodNode(path17.node.init);
|
|
12043
12075
|
if (schema) {
|
|
12044
|
-
this.
|
|
12076
|
+
const overrideId = this.extractMetaIdFromNode(path17.node.init);
|
|
12077
|
+
if (overrideId) {
|
|
12078
|
+
this.applyMetaIdOverride(schemaName, schema, overrideId, filePath);
|
|
12079
|
+
} else {
|
|
12080
|
+
this.storeResolvedSchema(schemaName, schema);
|
|
12081
|
+
}
|
|
12045
12082
|
}
|
|
12046
12083
|
return;
|
|
12047
12084
|
}
|
|
@@ -12384,8 +12421,15 @@ var ZodSchemaConverter = class {
|
|
|
12384
12421
|
};
|
|
12385
12422
|
switch (methodName) {
|
|
12386
12423
|
case "optional":
|
|
12424
|
+
break;
|
|
12387
12425
|
case "nullable":
|
|
12388
12426
|
case "nullish":
|
|
12427
|
+
schema = {
|
|
12428
|
+
anyOf: [
|
|
12429
|
+
{ $ref: `#/components/schemas/${this.getSchemaReferenceName(schemaName)}` },
|
|
12430
|
+
{ type: "null" }
|
|
12431
|
+
]
|
|
12432
|
+
};
|
|
12389
12433
|
break;
|
|
12390
12434
|
case "describe":
|
|
12391
12435
|
if (node.arguments.length > 0 && t10.isStringLiteral(node.arguments[0])) {
|
|
@@ -12903,12 +12947,16 @@ var ZodSchemaConverter = class {
|
|
|
12903
12947
|
case "optional":
|
|
12904
12948
|
break;
|
|
12905
12949
|
case "nullable":
|
|
12906
|
-
if (
|
|
12950
|
+
if (schema.allOf) {
|
|
12951
|
+
schema = { anyOf: [...schema.allOf, { type: "null" }] };
|
|
12952
|
+
} else {
|
|
12907
12953
|
schema.nullable = true;
|
|
12908
12954
|
}
|
|
12909
12955
|
break;
|
|
12910
12956
|
case "nullish":
|
|
12911
|
-
if (
|
|
12957
|
+
if (schema.allOf) {
|
|
12958
|
+
schema = { anyOf: [...schema.allOf, { type: "null" }] };
|
|
12959
|
+
} else {
|
|
12912
12960
|
schema.nullable = true;
|
|
12913
12961
|
}
|
|
12914
12962
|
break;
|
|
@@ -13353,7 +13401,13 @@ var ZodSchemaConverter = class {
|
|
|
13353
13401
|
* Get all processed Zod schemas
|
|
13354
13402
|
*/
|
|
13355
13403
|
getProcessedSchemas() {
|
|
13356
|
-
|
|
13404
|
+
const result = {};
|
|
13405
|
+
for (const [name, schema] of Object.entries(this.zodSchemas)) {
|
|
13406
|
+
if (!this.internalSchemaNames.has(name)) {
|
|
13407
|
+
result[name] = schema;
|
|
13408
|
+
}
|
|
13409
|
+
}
|
|
13410
|
+
return result;
|
|
13357
13411
|
}
|
|
13358
13412
|
/**
|
|
13359
13413
|
* Pre-scan all files to build type mappings
|
|
@@ -13405,9 +13459,21 @@ var ZodSchemaConverter = class {
|
|
|
13405
13459
|
if (t10.isIdentifier(declaration.id) && declaration.init) {
|
|
13406
13460
|
const schemaName = declaration.id.name;
|
|
13407
13461
|
if (this.isZodSchema(declaration.init)) {
|
|
13462
|
+
const decl = path17.node.declaration;
|
|
13463
|
+
const allComments = [
|
|
13464
|
+
...path17.node.leadingComments ?? [],
|
|
13465
|
+
...decl?.leadingComments ?? [],
|
|
13466
|
+
...declaration.leadingComments ?? []
|
|
13467
|
+
];
|
|
13468
|
+
if (extractInternalFlagFromComments(allComments)) {
|
|
13469
|
+
this.internalSchemaNames.add(schemaName);
|
|
13470
|
+
}
|
|
13408
13471
|
if (!this.getStoredSchema(schemaName)) {
|
|
13409
13472
|
logger.debug(`Pre-processing Zod schema: ${schemaName}`);
|
|
13410
13473
|
this.processingSchemas.add(schemaName);
|
|
13474
|
+
this.currentFilePath = filePath;
|
|
13475
|
+
this.currentAST = ast;
|
|
13476
|
+
this.currentImports = importedModules;
|
|
13411
13477
|
const schema = this.processZodNode(declaration.init);
|
|
13412
13478
|
this.processingSchemas.delete(schemaName);
|
|
13413
13479
|
if (schema) {
|
|
@@ -13430,9 +13496,19 @@ var ZodSchemaConverter = class {
|
|
|
13430
13496
|
if (t10.isIdentifier(declaration.id) && declaration.init) {
|
|
13431
13497
|
const schemaName = declaration.id.name;
|
|
13432
13498
|
if (this.isZodSchema(declaration.init)) {
|
|
13499
|
+
const allComments = [
|
|
13500
|
+
...path17.node.leadingComments ?? [],
|
|
13501
|
+
...declaration.leadingComments ?? []
|
|
13502
|
+
];
|
|
13503
|
+
if (extractInternalFlagFromComments(allComments)) {
|
|
13504
|
+
this.internalSchemaNames.add(schemaName);
|
|
13505
|
+
}
|
|
13433
13506
|
if (!this.getStoredSchema(schemaName) && !this.processingSchemas.has(schemaName)) {
|
|
13434
13507
|
logger.debug(`Pre-processing Zod schema: ${schemaName}`);
|
|
13435
13508
|
this.processingSchemas.add(schemaName);
|
|
13509
|
+
this.currentFilePath = filePath;
|
|
13510
|
+
this.currentAST = ast;
|
|
13511
|
+
this.currentImports = importedModules;
|
|
13436
13512
|
const schema = this.processZodNode(declaration.init);
|
|
13437
13513
|
this.processingSchemas.delete(schemaName);
|
|
13438
13514
|
if (schema) {
|
|
@@ -14164,7 +14240,7 @@ function collectFirstMemberLeadingComments(interfaceDecl) {
|
|
|
14164
14240
|
const firstMember = body.body?.[0];
|
|
14165
14241
|
return firstMember?.leadingComments ?? [];
|
|
14166
14242
|
}
|
|
14167
|
-
function collectAllExportedDefinitions(ast, typeDefinitions, currentFile, schemaIdAliases) {
|
|
14243
|
+
function collectAllExportedDefinitions(ast, typeDefinitions, currentFile, schemaIdAliases, internalSchemaNames) {
|
|
14168
14244
|
function registerDefinition(name, entry, allComments) {
|
|
14169
14245
|
if (!typeDefinitions[name]) {
|
|
14170
14246
|
typeDefinitions[name] = entry;
|
|
@@ -14176,6 +14252,9 @@ function collectAllExportedDefinitions(ast, typeDefinitions, currentFile, schema
|
|
|
14176
14252
|
typeDefinitions[overrideId] = entry;
|
|
14177
14253
|
}
|
|
14178
14254
|
}
|
|
14255
|
+
if (internalSchemaNames && extractInternalFlagFromComments(allComments)) {
|
|
14256
|
+
internalSchemaNames.add(name);
|
|
14257
|
+
}
|
|
14179
14258
|
}
|
|
14180
14259
|
resolvedTraverse(ast, {
|
|
14181
14260
|
TSTypeAliasDeclaration: (path17) => {
|
|
@@ -14655,6 +14734,7 @@ var SchemaProcessor = class {
|
|
|
14655
14734
|
schemaTypes;
|
|
14656
14735
|
isResolvingPickOmitBase = false;
|
|
14657
14736
|
schemaIdAliases = {};
|
|
14737
|
+
internalSchemaNames = /* @__PURE__ */ new Set();
|
|
14658
14738
|
fileAccess;
|
|
14659
14739
|
symbolResolver;
|
|
14660
14740
|
// Track imports per file for resolving ReturnType<typeof func>
|
|
@@ -14695,7 +14775,7 @@ var SchemaProcessor = class {
|
|
|
14695
14775
|
getDefinedSchemas() {
|
|
14696
14776
|
const filteredSchemas = {};
|
|
14697
14777
|
Object.entries(this.openapiDefinitions).forEach(([key, value]) => {
|
|
14698
|
-
if (!this.schemaIdAliases[key] && !this.isGenericTypeParameter(key) && !this.isInvalidSchemaName(key) && !this.isBuiltInUtilityType(key) && !this.isFunctionSchema(key)) {
|
|
14778
|
+
if (!this.schemaIdAliases[key] && !this.isGenericTypeParameter(key) && !this.isInvalidSchemaName(key) && !this.isBuiltInUtilityType(key) && !this.isFunctionSchema(key) && !this.internalSchemaNames.has(key)) {
|
|
14699
14779
|
filteredSchemas[key] = value;
|
|
14700
14780
|
}
|
|
14701
14781
|
});
|
|
@@ -14705,6 +14785,22 @@ var SchemaProcessor = class {
|
|
|
14705
14785
|
this.customSchemaProcessor.getDefinedSchemas()
|
|
14706
14786
|
]);
|
|
14707
14787
|
}
|
|
14788
|
+
getInternalSchemas() {
|
|
14789
|
+
const result = {};
|
|
14790
|
+
for (const name of this.internalSchemaNames) {
|
|
14791
|
+
const def = this.openapiDefinitions[name];
|
|
14792
|
+
if (def)
|
|
14793
|
+
result[name] = def;
|
|
14794
|
+
}
|
|
14795
|
+
if (this.zodSchemaConverter) {
|
|
14796
|
+
for (const name of this.zodSchemaConverter.internalSchemaNames) {
|
|
14797
|
+
const schema = this.zodSchemaConverter.zodSchemas[name];
|
|
14798
|
+
if (schema)
|
|
14799
|
+
result[name] = schema;
|
|
14800
|
+
}
|
|
14801
|
+
}
|
|
14802
|
+
return result;
|
|
14803
|
+
}
|
|
14708
14804
|
findSchemaDefinition(schemaName, contentType) {
|
|
14709
14805
|
this.contentType = contentType;
|
|
14710
14806
|
if (schemaName.includes("<") && schemaName.includes(">")) {
|
|
@@ -14855,7 +14951,7 @@ var SchemaProcessor = class {
|
|
|
14855
14951
|
* Used when processing imported files to ensure all referenced types are available
|
|
14856
14952
|
*/
|
|
14857
14953
|
collectAllExportedDefinitions(ast, filePath) {
|
|
14858
|
-
collectAllExportedDefinitions(ast, this.typeDefinitions, filePath || this.currentFilePath, this.schemaIdAliases);
|
|
14954
|
+
collectAllExportedDefinitions(ast, this.typeDefinitions, filePath || this.currentFilePath, this.schemaIdAliases, this.internalSchemaNames);
|
|
14859
14955
|
}
|
|
14860
14956
|
collectTypeDefinitions(ast, schemaName, filePath) {
|
|
14861
14957
|
collectTypeDefinitions(ast, schemaName, this.typeDefinitions, filePath || this.currentFilePath);
|
|
@@ -16283,11 +16379,16 @@ var ResponseProcessor = class {
|
|
|
16283
16379
|
var OperationProcessor = class {
|
|
16284
16380
|
schemaProcessor;
|
|
16285
16381
|
responseProcessor;
|
|
16382
|
+
authPresets;
|
|
16286
16383
|
performanceProfile;
|
|
16287
|
-
constructor(schemaProcessor, responseProcessor,
|
|
16384
|
+
constructor(schemaProcessor, responseProcessor, options = {}) {
|
|
16288
16385
|
this.schemaProcessor = schemaProcessor;
|
|
16289
16386
|
this.responseProcessor = responseProcessor;
|
|
16290
|
-
this.
|
|
16387
|
+
this.authPresets = {
|
|
16388
|
+
...DEFAULT_AUTH_PRESET_REPLACEMENTS,
|
|
16389
|
+
...options.authPresets
|
|
16390
|
+
};
|
|
16391
|
+
this.performanceProfile = options.performanceProfile;
|
|
16291
16392
|
}
|
|
16292
16393
|
processOperation(varName, routePath, dataTypes, pathParamNames = []) {
|
|
16293
16394
|
const method = varName.toLowerCase();
|
|
@@ -16312,9 +16413,10 @@ var OperationProcessor = class {
|
|
|
16312
16413
|
definition.deprecated = true;
|
|
16313
16414
|
}
|
|
16314
16415
|
if (explicitSecurity && explicitSecurity.length > 0) {
|
|
16315
|
-
definition.security = explicitSecurity;
|
|
16416
|
+
definition.security = explicitSecurity.map((req) => Object.fromEntries(Object.entries(req).map(([scheme, scopes]) => [this.applyPreset(scheme), scopes])));
|
|
16316
16417
|
} else if (auth) {
|
|
16317
|
-
const
|
|
16418
|
+
const mapped = performAuthPresetReplacements(auth, this.authPresets);
|
|
16419
|
+
const authItems = mapped.split(",").map((item) => item.trim());
|
|
16318
16420
|
definition.security = authItems.map((authItem) => ({
|
|
16319
16421
|
[authItem]: []
|
|
16320
16422
|
}));
|
|
@@ -16527,6 +16629,9 @@ ${suffix}`;
|
|
|
16527
16629
|
response.links[link.name] = linkObject;
|
|
16528
16630
|
}
|
|
16529
16631
|
}
|
|
16632
|
+
applyPreset(scheme) {
|
|
16633
|
+
return this.authPresets[scheme.toLowerCase()] ?? scheme;
|
|
16634
|
+
}
|
|
16530
16635
|
createQuerystringParameter(dataTypes) {
|
|
16531
16636
|
if (!dataTypes.querystringType) {
|
|
16532
16637
|
return void 0;
|
|
@@ -16615,7 +16720,10 @@ var RouteProcessor = class {
|
|
|
16615
16720
|
return new RegExp(`^${regexPattern}$`);
|
|
16616
16721
|
});
|
|
16617
16722
|
this.responseProcessor = new ResponseProcessor(this.config, this.schemaProcessor);
|
|
16618
|
-
this.operationProcessor = new OperationProcessor(this.schemaProcessor, this.responseProcessor,
|
|
16723
|
+
this.operationProcessor = new OperationProcessor(this.schemaProcessor, this.responseProcessor, {
|
|
16724
|
+
authPresets: this.config.authPresets,
|
|
16725
|
+
performanceProfile: this.performanceProfile
|
|
16726
|
+
});
|
|
16619
16727
|
}
|
|
16620
16728
|
processResponsesFromConfig(dataTypes, method) {
|
|
16621
16729
|
return this.responseProcessor.processResponses(dataTypes, method);
|
|
@@ -16841,6 +16949,64 @@ function generateErrorResponsesFromConfig(document, errorConfig) {
|
|
|
16841
16949
|
});
|
|
16842
16950
|
}
|
|
16843
16951
|
|
|
16952
|
+
// ../openapi-core/dist/core/exclude-schemas.js
|
|
16953
|
+
function patternToRegExp(pattern) {
|
|
16954
|
+
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
16955
|
+
return new RegExp(`^${escaped.replace(/\*/g, ".*")}$`);
|
|
16956
|
+
}
|
|
16957
|
+
function matchExcludePatterns(names, patterns) {
|
|
16958
|
+
if (patterns.length === 0)
|
|
16959
|
+
return [];
|
|
16960
|
+
const regexes = patterns.map(patternToRegExp);
|
|
16961
|
+
return names.filter((name) => regexes.some((re) => re.test(name)));
|
|
16962
|
+
}
|
|
16963
|
+
function applyExcludeSchemas(document, mergedSchemas, excludedSchemas) {
|
|
16964
|
+
const excludedNames = new Set(Object.keys(excludedSchemas));
|
|
16965
|
+
if (excludedNames.size === 0)
|
|
16966
|
+
return;
|
|
16967
|
+
walkAndInline(document, excludedSchemas, excludedNames, /* @__PURE__ */ new Set());
|
|
16968
|
+
for (const name of excludedNames) {
|
|
16969
|
+
delete mergedSchemas[name];
|
|
16970
|
+
}
|
|
16971
|
+
}
|
|
16972
|
+
function walkAndInline(obj, excluded, excludedNames, visiting) {
|
|
16973
|
+
if (!obj || typeof obj !== "object")
|
|
16974
|
+
return;
|
|
16975
|
+
if (Array.isArray(obj)) {
|
|
16976
|
+
for (const item of obj) {
|
|
16977
|
+
walkAndInline(item, excluded, excludedNames, visiting);
|
|
16978
|
+
}
|
|
16979
|
+
return;
|
|
16980
|
+
}
|
|
16981
|
+
const rec = obj;
|
|
16982
|
+
const ref = rec["$ref"];
|
|
16983
|
+
if (typeof ref === "string") {
|
|
16984
|
+
const match = ref.match(/^#\/components\/schemas\/(.+)$/);
|
|
16985
|
+
const name = match?.[1];
|
|
16986
|
+
if (name && excludedNames.has(name)) {
|
|
16987
|
+
if (visiting.has(name)) {
|
|
16988
|
+
logger.warn(`Circular reference to internal schema "${name}", keeping $ref`);
|
|
16989
|
+
return;
|
|
16990
|
+
}
|
|
16991
|
+
const schemaDef = excluded[name];
|
|
16992
|
+
if (schemaDef) {
|
|
16993
|
+
const cloned = JSON.parse(JSON.stringify(schemaDef));
|
|
16994
|
+
delete rec["$ref"];
|
|
16995
|
+
Object.assign(rec, cloned);
|
|
16996
|
+
const newVisiting = new Set(visiting);
|
|
16997
|
+
newVisiting.add(name);
|
|
16998
|
+
for (const key of Object.keys(rec)) {
|
|
16999
|
+
walkAndInline(rec[key], excluded, excludedNames, newVisiting);
|
|
17000
|
+
}
|
|
17001
|
+
return;
|
|
17002
|
+
}
|
|
17003
|
+
}
|
|
17004
|
+
}
|
|
17005
|
+
for (const key of Object.keys(rec)) {
|
|
17006
|
+
walkAndInline(rec[key], excluded, excludedNames, visiting);
|
|
17007
|
+
}
|
|
17008
|
+
}
|
|
17009
|
+
|
|
16844
17010
|
// ../openapi-core/dist/core/orchestrator.js
|
|
16845
17011
|
function runGenerationOrchestrator({ config: config2, template, hooks, runtime, createFrameworkSource }) {
|
|
16846
17012
|
const diagnostics = new DiagnosticsCollector();
|
|
@@ -16911,11 +17077,21 @@ function runGenerationOrchestrator({ config: config2, template, hooks, runtime,
|
|
|
16911
17077
|
}
|
|
16912
17078
|
profile.defaultComponentsAndErrorsMs = performance.now() - phaseStartedAt;
|
|
16913
17079
|
phaseStartedAt = performance.now();
|
|
16914
|
-
const
|
|
17080
|
+
const schemaProcessor = routeProcessor.getSchemaProcessor();
|
|
17081
|
+
const definedSchemas = schemaProcessor.getDefinedSchemas();
|
|
16915
17082
|
const mergedSchemas = {
|
|
16916
17083
|
...document.components.schemas,
|
|
16917
17084
|
...definedSchemas
|
|
16918
17085
|
};
|
|
17086
|
+
const internalSchemas = schemaProcessor.getInternalSchemas();
|
|
17087
|
+
const patternExcludedNames = matchExcludePatterns(Object.keys(mergedSchemas), config2.excludeSchemas ?? []);
|
|
17088
|
+
const allExcludedSchemas = {
|
|
17089
|
+
...internalSchemas,
|
|
17090
|
+
...Object.fromEntries(patternExcludedNames.map((name) => [name, mergedSchemas[name]]))
|
|
17091
|
+
};
|
|
17092
|
+
if (Object.keys(allExcludedSchemas).length > 0) {
|
|
17093
|
+
applyExcludeSchemas(document, mergedSchemas, allExcludedSchemas);
|
|
17094
|
+
}
|
|
16919
17095
|
if (Object.keys(mergedSchemas).length > 0) {
|
|
16920
17096
|
document.components.schemas = Object.fromEntries(Object.entries(mergedSchemas).sort(([a], [b]) => a.localeCompare(b, "en", { sensitivity: "base" })));
|
|
16921
17097
|
}
|