next-openapi-gen 1.3.0 → 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 +15 -13
- package/dist/cli.js +189 -138
- package/dist/index.js +189 -138
- package/dist/next/index.js +73 -22
- package/dist/react-router/index.js +73 -22
- package/dist/vite/index.js +73 -22
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -132,122 +132,6 @@ var FrameworkKind;
|
|
|
132
132
|
FrameworkKind2["ReactRouter"] = "reactrouter";
|
|
133
133
|
})(FrameworkKind || (FrameworkKind = {}));
|
|
134
134
|
|
|
135
|
-
// ../openapi-core/dist/config/normalize.js
|
|
136
|
-
function normalizeRouterType(routerType) {
|
|
137
|
-
return routerType ?? DEFAULT_ROUTER_TYPE;
|
|
138
|
-
}
|
|
139
|
-
function normalizeSchemaTypes(schemaType) {
|
|
140
|
-
const schemaBackends = Array.isArray(schemaType) ? schemaType : [schemaType ?? DEFAULT_RUNTIME_SCHEMA_TYPE];
|
|
141
|
-
return [...new Set(schemaBackends)];
|
|
142
|
-
}
|
|
143
|
-
function normalizeOpenApiVersion(template) {
|
|
144
|
-
if (template.openapi.startsWith("3.2")) {
|
|
145
|
-
return "3.2";
|
|
146
|
-
}
|
|
147
|
-
if (template.openapi.startsWith("3.1")) {
|
|
148
|
-
return "3.1";
|
|
149
|
-
}
|
|
150
|
-
if (template.openapi.startsWith("4.")) {
|
|
151
|
-
return "4.0";
|
|
152
|
-
}
|
|
153
|
-
return DEFAULT_OPENAPI_VERSION;
|
|
154
|
-
}
|
|
155
|
-
function normalizeFrameworkKind(kind) {
|
|
156
|
-
switch (kind) {
|
|
157
|
-
case FrameworkKind.Nextjs:
|
|
158
|
-
case "next":
|
|
159
|
-
return FrameworkKind.Nextjs;
|
|
160
|
-
case FrameworkKind.Tanstack:
|
|
161
|
-
case "tanstack":
|
|
162
|
-
return FrameworkKind.Tanstack;
|
|
163
|
-
case FrameworkKind.ReactRouter:
|
|
164
|
-
case "react-router":
|
|
165
|
-
return FrameworkKind.ReactRouter;
|
|
166
|
-
default:
|
|
167
|
-
return FrameworkKind.Nextjs;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function normalizeFramework(config2, routerType) {
|
|
171
|
-
if (config2.framework) {
|
|
172
|
-
const frameworkKind = normalizeFrameworkKind(config2.framework.kind);
|
|
173
|
-
switch (frameworkKind) {
|
|
174
|
-
case FrameworkKind.Nextjs:
|
|
175
|
-
return {
|
|
176
|
-
...config2.framework,
|
|
177
|
-
kind: frameworkKind,
|
|
178
|
-
router: config2.framework.router || routerType,
|
|
179
|
-
modulePath: config2.framework.modulePath || config2.framework.adapterPath || config2.next?.adapterPath,
|
|
180
|
-
adapterPath: config2.framework.adapterPath || config2.next?.adapterPath
|
|
181
|
-
};
|
|
182
|
-
case FrameworkKind.Tanstack:
|
|
183
|
-
case FrameworkKind.ReactRouter:
|
|
184
|
-
return {
|
|
185
|
-
...config2.framework,
|
|
186
|
-
kind: frameworkKind,
|
|
187
|
-
modulePath: config2.framework.modulePath || config2.framework.adapterPath
|
|
188
|
-
};
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
kind: FrameworkKind.Nextjs,
|
|
193
|
-
router: routerType,
|
|
194
|
-
modulePath: config2.next?.adapterPath,
|
|
195
|
-
adapterPath: config2.next?.adapterPath
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function normalizeOpenApiConfig(template) {
|
|
199
|
-
const routerType = normalizeRouterType(template.routerType);
|
|
200
|
-
const schemaBackends = normalizeSchemaTypes(template.schemaType);
|
|
201
|
-
const openapiVersion = normalizeOpenApiVersion({
|
|
202
|
-
openapi: "openapi" in template ? template.openapi || "3.0.0" : "3.0.0"
|
|
203
|
-
});
|
|
204
|
-
return {
|
|
205
|
-
apiDir: template.apiDir ?? DEFAULT_API_DIR,
|
|
206
|
-
routerType,
|
|
207
|
-
schemaDir: template.schemaDir ?? DEFAULT_SCHEMA_DIR,
|
|
208
|
-
docsUrl: template.docsUrl ?? DEFAULT_DOCS_URL,
|
|
209
|
-
ui: template.ui ?? DEFAULT_UI,
|
|
210
|
-
outputFile: template.outputFile ?? DEFAULT_GENERATED_OPENAPI_FILENAME,
|
|
211
|
-
outputDir: template.outputDir ?? DEFAULT_OUTPUT_DIR,
|
|
212
|
-
includeOpenApiRoutes: template.includeOpenApiRoutes ?? DEFAULT_INCLUDE_OPENAPI_ROUTES,
|
|
213
|
-
ignoreRoutes: template.ignoreRoutes ?? [],
|
|
214
|
-
excludeSchemas: template.excludeSchemas ?? [],
|
|
215
|
-
schemaType: template.schemaType ?? DEFAULT_RUNTIME_SCHEMA_TYPE,
|
|
216
|
-
schemaBackends,
|
|
217
|
-
schemaFiles: template.schemaFiles ?? [],
|
|
218
|
-
defaultResponseSet: template.defaultResponseSet,
|
|
219
|
-
responseSets: template.responseSets,
|
|
220
|
-
errorConfig: template.errorConfig,
|
|
221
|
-
errorDefinitions: template.errorDefinitions,
|
|
222
|
-
openapiVersion,
|
|
223
|
-
framework: normalizeFramework(template, routerType),
|
|
224
|
-
next: {
|
|
225
|
-
adapterPath: template.next?.adapterPath
|
|
226
|
-
},
|
|
227
|
-
diagnostics: template.diagnostics ?? { enabled: DEFAULT_DIAGNOSTICS_ENABLED },
|
|
228
|
-
debug: template.debug ?? DEFAULT_DEBUG
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
// ../openapi-core/dist/diagnostics/collector.js
|
|
233
|
-
var DiagnosticsCollector = class {
|
|
234
|
-
diagnostics = [];
|
|
235
|
-
add(diagnostic) {
|
|
236
|
-
this.diagnostics.push(diagnostic);
|
|
237
|
-
}
|
|
238
|
-
getAll() {
|
|
239
|
-
return [...this.diagnostics];
|
|
240
|
-
}
|
|
241
|
-
hasAny() {
|
|
242
|
-
return this.diagnostics.length > 0;
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
// ../openapi-core/dist/openapi/document.js
|
|
247
|
-
function createDocumentFromTemplate(template) {
|
|
248
|
-
return structuredClone(template);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
135
|
// ../openapi-core/dist/shared/utils.js
|
|
252
136
|
import { parse } from "@babel/parser";
|
|
253
137
|
import * as t from "@babel/types";
|
|
@@ -583,7 +467,7 @@ function parseJSDocBlock(commentValue, filePath) {
|
|
|
583
467
|
result.cookieType = extractTypeFromComment(normalizedComment, "@cookie");
|
|
584
468
|
const authValue = extractLineValue(normalizedComment, "@auth");
|
|
585
469
|
if (authValue) {
|
|
586
|
-
result.auth =
|
|
470
|
+
result.auth = authValue;
|
|
587
471
|
}
|
|
588
472
|
const querystring = parseQuerystringTag(normalizedComment);
|
|
589
473
|
if (querystring) {
|
|
@@ -1259,16 +1143,17 @@ var INTERNAL_OPENAPI_CONFIG_KEYS = [
|
|
|
1259
1143
|
"next",
|
|
1260
1144
|
"diagnostics",
|
|
1261
1145
|
"debug",
|
|
1146
|
+
"authPresets",
|
|
1262
1147
|
"excludeSchemas"
|
|
1263
1148
|
];
|
|
1264
|
-
var
|
|
1149
|
+
var DEFAULT_AUTH_PRESET_REPLACEMENTS = {
|
|
1265
1150
|
bearer: "BearerAuth",
|
|
1266
1151
|
basic: "BasicAuth",
|
|
1267
1152
|
apikey: "ApiKeyAuth"
|
|
1268
1153
|
};
|
|
1269
|
-
function performAuthPresetReplacements(authValue) {
|
|
1154
|
+
function performAuthPresetReplacements(authValue, presets = DEFAULT_AUTH_PRESET_REPLACEMENTS) {
|
|
1270
1155
|
const authParts = authValue.split(",").map((part) => part.trim());
|
|
1271
|
-
const mappedParts = authParts.map((part) =>
|
|
1156
|
+
const mappedParts = authParts.map((part) => presets[part.toLowerCase()] || part);
|
|
1272
1157
|
return mappedParts.join(",");
|
|
1273
1158
|
}
|
|
1274
1159
|
function getOperationId(routePath, method) {
|
|
@@ -1286,6 +1171,123 @@ function parseTypeScriptFile(content, options) {
|
|
|
1286
1171
|
});
|
|
1287
1172
|
}
|
|
1288
1173
|
|
|
1174
|
+
// ../openapi-core/dist/config/normalize.js
|
|
1175
|
+
function normalizeRouterType(routerType) {
|
|
1176
|
+
return routerType ?? DEFAULT_ROUTER_TYPE;
|
|
1177
|
+
}
|
|
1178
|
+
function normalizeSchemaTypes(schemaType) {
|
|
1179
|
+
const schemaBackends = Array.isArray(schemaType) ? schemaType : [schemaType ?? DEFAULT_RUNTIME_SCHEMA_TYPE];
|
|
1180
|
+
return [...new Set(schemaBackends)];
|
|
1181
|
+
}
|
|
1182
|
+
function normalizeOpenApiVersion(template) {
|
|
1183
|
+
if (template.openapi.startsWith("3.2")) {
|
|
1184
|
+
return "3.2";
|
|
1185
|
+
}
|
|
1186
|
+
if (template.openapi.startsWith("3.1")) {
|
|
1187
|
+
return "3.1";
|
|
1188
|
+
}
|
|
1189
|
+
if (template.openapi.startsWith("4.")) {
|
|
1190
|
+
return "4.0";
|
|
1191
|
+
}
|
|
1192
|
+
return DEFAULT_OPENAPI_VERSION;
|
|
1193
|
+
}
|
|
1194
|
+
function normalizeFrameworkKind(kind) {
|
|
1195
|
+
switch (kind) {
|
|
1196
|
+
case FrameworkKind.Nextjs:
|
|
1197
|
+
case "next":
|
|
1198
|
+
return FrameworkKind.Nextjs;
|
|
1199
|
+
case FrameworkKind.Tanstack:
|
|
1200
|
+
case "tanstack":
|
|
1201
|
+
return FrameworkKind.Tanstack;
|
|
1202
|
+
case FrameworkKind.ReactRouter:
|
|
1203
|
+
case "react-router":
|
|
1204
|
+
return FrameworkKind.ReactRouter;
|
|
1205
|
+
default:
|
|
1206
|
+
return FrameworkKind.Nextjs;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
function normalizeFramework(config2, routerType) {
|
|
1210
|
+
if (config2.framework) {
|
|
1211
|
+
const frameworkKind = normalizeFrameworkKind(config2.framework.kind);
|
|
1212
|
+
switch (frameworkKind) {
|
|
1213
|
+
case FrameworkKind.Nextjs:
|
|
1214
|
+
return {
|
|
1215
|
+
...config2.framework,
|
|
1216
|
+
kind: frameworkKind,
|
|
1217
|
+
router: config2.framework.router || routerType,
|
|
1218
|
+
modulePath: config2.framework.modulePath || config2.framework.adapterPath || config2.next?.adapterPath,
|
|
1219
|
+
adapterPath: config2.framework.adapterPath || config2.next?.adapterPath
|
|
1220
|
+
};
|
|
1221
|
+
case FrameworkKind.Tanstack:
|
|
1222
|
+
case FrameworkKind.ReactRouter:
|
|
1223
|
+
return {
|
|
1224
|
+
...config2.framework,
|
|
1225
|
+
kind: frameworkKind,
|
|
1226
|
+
modulePath: config2.framework.modulePath || config2.framework.adapterPath
|
|
1227
|
+
};
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
return {
|
|
1231
|
+
kind: FrameworkKind.Nextjs,
|
|
1232
|
+
router: routerType,
|
|
1233
|
+
modulePath: config2.next?.adapterPath,
|
|
1234
|
+
adapterPath: config2.next?.adapterPath
|
|
1235
|
+
};
|
|
1236
|
+
}
|
|
1237
|
+
function normalizeOpenApiConfig(template) {
|
|
1238
|
+
const routerType = normalizeRouterType(template.routerType);
|
|
1239
|
+
const schemaBackends = normalizeSchemaTypes(template.schemaType);
|
|
1240
|
+
const openapiVersion = normalizeOpenApiVersion({
|
|
1241
|
+
openapi: "openapi" in template ? template.openapi || "3.0.0" : "3.0.0"
|
|
1242
|
+
});
|
|
1243
|
+
return {
|
|
1244
|
+
apiDir: template.apiDir ?? DEFAULT_API_DIR,
|
|
1245
|
+
routerType,
|
|
1246
|
+
schemaDir: template.schemaDir ?? DEFAULT_SCHEMA_DIR,
|
|
1247
|
+
docsUrl: template.docsUrl ?? DEFAULT_DOCS_URL,
|
|
1248
|
+
ui: template.ui ?? DEFAULT_UI,
|
|
1249
|
+
outputFile: template.outputFile ?? DEFAULT_GENERATED_OPENAPI_FILENAME,
|
|
1250
|
+
outputDir: template.outputDir ?? DEFAULT_OUTPUT_DIR,
|
|
1251
|
+
includeOpenApiRoutes: template.includeOpenApiRoutes ?? DEFAULT_INCLUDE_OPENAPI_ROUTES,
|
|
1252
|
+
ignoreRoutes: template.ignoreRoutes ?? [],
|
|
1253
|
+
excludeSchemas: template.excludeSchemas ?? [],
|
|
1254
|
+
schemaType: template.schemaType ?? DEFAULT_RUNTIME_SCHEMA_TYPE,
|
|
1255
|
+
schemaBackends,
|
|
1256
|
+
schemaFiles: template.schemaFiles ?? [],
|
|
1257
|
+
defaultResponseSet: template.defaultResponseSet,
|
|
1258
|
+
responseSets: template.responseSets,
|
|
1259
|
+
errorConfig: template.errorConfig,
|
|
1260
|
+
errorDefinitions: template.errorDefinitions,
|
|
1261
|
+
openapiVersion,
|
|
1262
|
+
framework: normalizeFramework(template, routerType),
|
|
1263
|
+
next: {
|
|
1264
|
+
adapterPath: template.next?.adapterPath
|
|
1265
|
+
},
|
|
1266
|
+
diagnostics: template.diagnostics ?? { enabled: DEFAULT_DIAGNOSTICS_ENABLED },
|
|
1267
|
+
authPresets: { ...DEFAULT_AUTH_PRESET_REPLACEMENTS, ...template.authPresets },
|
|
1268
|
+
debug: template.debug ?? DEFAULT_DEBUG
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
// ../openapi-core/dist/diagnostics/collector.js
|
|
1273
|
+
var DiagnosticsCollector = class {
|
|
1274
|
+
diagnostics = [];
|
|
1275
|
+
add(diagnostic) {
|
|
1276
|
+
this.diagnostics.push(diagnostic);
|
|
1277
|
+
}
|
|
1278
|
+
getAll() {
|
|
1279
|
+
return [...this.diagnostics];
|
|
1280
|
+
}
|
|
1281
|
+
hasAny() {
|
|
1282
|
+
return this.diagnostics.length > 0;
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
// ../openapi-core/dist/openapi/document.js
|
|
1287
|
+
function createDocumentFromTemplate(template) {
|
|
1288
|
+
return structuredClone(template);
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1289
1291
|
// ../openapi-core/dist/openapi/version-processor.js
|
|
1290
1292
|
var DefaultOpenApiVersionProcessor = class {
|
|
1291
1293
|
id;
|
|
@@ -1744,8 +1746,10 @@ function downgradeSchemaForOpenApi30(schema, mediaTypeName) {
|
|
|
1744
1746
|
const nullableBranch = nextSchema.anyOf.find((item) => item.type === "null");
|
|
1745
1747
|
const baseBranch = nextSchema.anyOf.find((item) => item.type !== "null");
|
|
1746
1748
|
if (nullableBranch && baseBranch) {
|
|
1749
|
+
const { anyOf: _anyOf, ...outerMeta } = nextSchema;
|
|
1747
1750
|
nextSchema = {
|
|
1748
1751
|
...structuredClone(baseBranch),
|
|
1752
|
+
...outerMeta,
|
|
1749
1753
|
nullable: true
|
|
1750
1754
|
};
|
|
1751
1755
|
}
|
|
@@ -3665,7 +3669,7 @@ function processZodLiteral(node, context) {
|
|
|
3665
3669
|
return { type: "string", enum: [arg.value] };
|
|
3666
3670
|
}
|
|
3667
3671
|
if (t8.isNumericLiteral(arg)) {
|
|
3668
|
-
return { type: "number", enum: [arg.value] };
|
|
3672
|
+
return { type: Number.isInteger(arg.value) ? "integer" : "number", enum: [arg.value] };
|
|
3669
3673
|
}
|
|
3670
3674
|
if (t8.isBooleanLiteral(arg)) {
|
|
3671
3675
|
return { type: "boolean", enum: [arg.value] };
|
|
@@ -3681,7 +3685,7 @@ function processZodLiteral(node, context) {
|
|
|
3681
3685
|
if (typeof value === "string")
|
|
3682
3686
|
return { type: "string", enum: [value] };
|
|
3683
3687
|
if (typeof value === "number")
|
|
3684
|
-
return { type: "number", enum: [value] };
|
|
3688
|
+
return { type: Number.isInteger(value) ? "integer" : "number", enum: [value] };
|
|
3685
3689
|
if (typeof value === "boolean")
|
|
3686
3690
|
return { type: "boolean", enum: [value] };
|
|
3687
3691
|
if (value === null)
|
|
@@ -3776,7 +3780,7 @@ function processZodTuple(node, processNode, context) {
|
|
|
3776
3780
|
if (t8.isIdentifier(node.arguments[0]) && context?.resolveConstArrayValues) {
|
|
3777
3781
|
const values = context.resolveConstArrayValues(node.arguments[0].name);
|
|
3778
3782
|
if (values && values.length > 0) {
|
|
3779
|
-
const prefixItems = values.map((value) => typeof value === "number" ? { type: "number", enum: [value] } : { type: "string", enum: [value] });
|
|
3783
|
+
const prefixItems = values.map((value) => typeof value === "number" ? { type: Number.isInteger(value) ? "integer" : "number", enum: [value] } : { type: "string", enum: [value] });
|
|
3780
3784
|
return {
|
|
3781
3785
|
type: "array",
|
|
3782
3786
|
prefixItems,
|
|
@@ -3820,7 +3824,7 @@ function processZodUnion(node, processNode, context) {
|
|
|
3820
3824
|
if (t8.isIdentifier(node.arguments[0]) && context?.resolveConstArrayValues) {
|
|
3821
3825
|
const values = context.resolveConstArrayValues(node.arguments[0].name);
|
|
3822
3826
|
if (values && values.length > 0) {
|
|
3823
|
-
const type = typeof values[0] === "number" ? "number" : "string";
|
|
3827
|
+
const type = typeof values[0] === "number" ? Number.isInteger(values[0]) ? "integer" : "number" : "string";
|
|
3824
3828
|
return { type, enum: values };
|
|
3825
3829
|
}
|
|
3826
3830
|
}
|
|
@@ -11267,8 +11271,17 @@ var ZodRuntimeExporter = class {
|
|
|
11267
11271
|
return node.arguments[0] ? literal(this.buildLiteralValue(node.arguments[0])) : null;
|
|
11268
11272
|
case "enum":
|
|
11269
11273
|
return this.buildEnum(node);
|
|
11270
|
-
case "array":
|
|
11271
|
-
|
|
11274
|
+
case "array": {
|
|
11275
|
+
const arg = node.arguments[0];
|
|
11276
|
+
if (!arg || !isProcessableNode(arg)) {
|
|
11277
|
+
return array(unknown());
|
|
11278
|
+
}
|
|
11279
|
+
const itemSchema = this.buildSchema(arg);
|
|
11280
|
+
if (!itemSchema) {
|
|
11281
|
+
return null;
|
|
11282
|
+
}
|
|
11283
|
+
return array(itemSchema);
|
|
11284
|
+
}
|
|
11272
11285
|
case "strictObject": {
|
|
11273
11286
|
const base = this.buildObject(node);
|
|
11274
11287
|
return base && typeof base.strict === "function" ? base.strict() : base;
|
|
@@ -11400,13 +11413,17 @@ var ZodRuntimeExporter = class {
|
|
|
11400
11413
|
if (node.arguments.length === 0 || !t9.isArrayExpression(node.arguments[0])) {
|
|
11401
11414
|
return tuple([]);
|
|
11402
11415
|
}
|
|
11403
|
-
const items =
|
|
11416
|
+
const items = [];
|
|
11417
|
+
for (const element of node.arguments[0].elements) {
|
|
11404
11418
|
if (!isProcessableNode(element)) {
|
|
11405
|
-
return
|
|
11419
|
+
return null;
|
|
11406
11420
|
}
|
|
11407
11421
|
const schema = this.buildSchema(element);
|
|
11408
|
-
|
|
11409
|
-
|
|
11422
|
+
if (!schema) {
|
|
11423
|
+
return null;
|
|
11424
|
+
}
|
|
11425
|
+
items.push(schema);
|
|
11426
|
+
}
|
|
11410
11427
|
return tuple(items);
|
|
11411
11428
|
}
|
|
11412
11429
|
buildTemplateLiteral(node) {
|
|
@@ -12018,7 +12035,12 @@ var ZodSchemaConverter = class {
|
|
|
12018
12035
|
if (this.isZodSchema(path25.node.init)) {
|
|
12019
12036
|
const schema = this.processZodNode(path25.node.init);
|
|
12020
12037
|
if (schema) {
|
|
12021
|
-
this.
|
|
12038
|
+
const overrideId = this.extractMetaIdFromNode(path25.node.init);
|
|
12039
|
+
if (overrideId) {
|
|
12040
|
+
this.applyMetaIdOverride(schemaName, schema, overrideId, filePath);
|
|
12041
|
+
} else {
|
|
12042
|
+
this.storeResolvedSchema(schemaName, schema);
|
|
12043
|
+
}
|
|
12022
12044
|
}
|
|
12023
12045
|
return;
|
|
12024
12046
|
}
|
|
@@ -12361,8 +12383,15 @@ var ZodSchemaConverter = class {
|
|
|
12361
12383
|
};
|
|
12362
12384
|
switch (methodName) {
|
|
12363
12385
|
case "optional":
|
|
12386
|
+
break;
|
|
12364
12387
|
case "nullable":
|
|
12365
12388
|
case "nullish":
|
|
12389
|
+
schema = {
|
|
12390
|
+
anyOf: [
|
|
12391
|
+
{ $ref: `#/components/schemas/${this.getSchemaReferenceName(schemaName)}` },
|
|
12392
|
+
{ type: "null" }
|
|
12393
|
+
]
|
|
12394
|
+
};
|
|
12366
12395
|
break;
|
|
12367
12396
|
case "describe":
|
|
12368
12397
|
if (node.arguments.length > 0 && t10.isStringLiteral(node.arguments[0])) {
|
|
@@ -12880,12 +12909,16 @@ var ZodSchemaConverter = class {
|
|
|
12880
12909
|
case "optional":
|
|
12881
12910
|
break;
|
|
12882
12911
|
case "nullable":
|
|
12883
|
-
if (
|
|
12912
|
+
if (schema.allOf) {
|
|
12913
|
+
schema = { anyOf: [...schema.allOf, { type: "null" }] };
|
|
12914
|
+
} else {
|
|
12884
12915
|
schema.nullable = true;
|
|
12885
12916
|
}
|
|
12886
12917
|
break;
|
|
12887
12918
|
case "nullish":
|
|
12888
|
-
if (
|
|
12919
|
+
if (schema.allOf) {
|
|
12920
|
+
schema = { anyOf: [...schema.allOf, { type: "null" }] };
|
|
12921
|
+
} else {
|
|
12889
12922
|
schema.nullable = true;
|
|
12890
12923
|
}
|
|
12891
12924
|
break;
|
|
@@ -13400,6 +13433,9 @@ var ZodSchemaConverter = class {
|
|
|
13400
13433
|
if (!this.getStoredSchema(schemaName)) {
|
|
13401
13434
|
logger.debug(`Pre-processing Zod schema: ${schemaName}`);
|
|
13402
13435
|
this.processingSchemas.add(schemaName);
|
|
13436
|
+
this.currentFilePath = filePath;
|
|
13437
|
+
this.currentAST = ast;
|
|
13438
|
+
this.currentImports = importedModules;
|
|
13403
13439
|
const schema = this.processZodNode(declaration.init);
|
|
13404
13440
|
this.processingSchemas.delete(schemaName);
|
|
13405
13441
|
if (schema) {
|
|
@@ -13432,6 +13468,9 @@ var ZodSchemaConverter = class {
|
|
|
13432
13468
|
if (!this.getStoredSchema(schemaName) && !this.processingSchemas.has(schemaName)) {
|
|
13433
13469
|
logger.debug(`Pre-processing Zod schema: ${schemaName}`);
|
|
13434
13470
|
this.processingSchemas.add(schemaName);
|
|
13471
|
+
this.currentFilePath = filePath;
|
|
13472
|
+
this.currentAST = ast;
|
|
13473
|
+
this.currentImports = importedModules;
|
|
13435
13474
|
const schema = this.processZodNode(declaration.init);
|
|
13436
13475
|
this.processingSchemas.delete(schemaName);
|
|
13437
13476
|
if (schema) {
|
|
@@ -16302,11 +16341,16 @@ var ResponseProcessor = class {
|
|
|
16302
16341
|
var OperationProcessor = class {
|
|
16303
16342
|
schemaProcessor;
|
|
16304
16343
|
responseProcessor;
|
|
16344
|
+
authPresets;
|
|
16305
16345
|
performanceProfile;
|
|
16306
|
-
constructor(schemaProcessor, responseProcessor,
|
|
16346
|
+
constructor(schemaProcessor, responseProcessor, options = {}) {
|
|
16307
16347
|
this.schemaProcessor = schemaProcessor;
|
|
16308
16348
|
this.responseProcessor = responseProcessor;
|
|
16309
|
-
this.
|
|
16349
|
+
this.authPresets = {
|
|
16350
|
+
...DEFAULT_AUTH_PRESET_REPLACEMENTS,
|
|
16351
|
+
...options.authPresets
|
|
16352
|
+
};
|
|
16353
|
+
this.performanceProfile = options.performanceProfile;
|
|
16310
16354
|
}
|
|
16311
16355
|
processOperation(varName, routePath, dataTypes, pathParamNames = []) {
|
|
16312
16356
|
const method = varName.toLowerCase();
|
|
@@ -16331,9 +16375,10 @@ var OperationProcessor = class {
|
|
|
16331
16375
|
definition.deprecated = true;
|
|
16332
16376
|
}
|
|
16333
16377
|
if (explicitSecurity && explicitSecurity.length > 0) {
|
|
16334
|
-
definition.security = explicitSecurity;
|
|
16378
|
+
definition.security = explicitSecurity.map((req) => Object.fromEntries(Object.entries(req).map(([scheme, scopes]) => [this.applyPreset(scheme), scopes])));
|
|
16335
16379
|
} else if (auth) {
|
|
16336
|
-
const
|
|
16380
|
+
const mapped = performAuthPresetReplacements(auth, this.authPresets);
|
|
16381
|
+
const authItems = mapped.split(",").map((item) => item.trim());
|
|
16337
16382
|
definition.security = authItems.map((authItem) => ({
|
|
16338
16383
|
[authItem]: []
|
|
16339
16384
|
}));
|
|
@@ -16546,6 +16591,9 @@ ${suffix}`;
|
|
|
16546
16591
|
response.links[link.name] = linkObject;
|
|
16547
16592
|
}
|
|
16548
16593
|
}
|
|
16594
|
+
applyPreset(scheme) {
|
|
16595
|
+
return this.authPresets[scheme.toLowerCase()] ?? scheme;
|
|
16596
|
+
}
|
|
16549
16597
|
createQuerystringParameter(dataTypes) {
|
|
16550
16598
|
if (!dataTypes.querystringType) {
|
|
16551
16599
|
return void 0;
|
|
@@ -16634,7 +16682,10 @@ var RouteProcessor = class {
|
|
|
16634
16682
|
return new RegExp(`^${regexPattern}$`);
|
|
16635
16683
|
});
|
|
16636
16684
|
this.responseProcessor = new ResponseProcessor(this.config, this.schemaProcessor);
|
|
16637
|
-
this.operationProcessor = new OperationProcessor(this.schemaProcessor, this.responseProcessor,
|
|
16685
|
+
this.operationProcessor = new OperationProcessor(this.schemaProcessor, this.responseProcessor, {
|
|
16686
|
+
authPresets: this.config.authPresets,
|
|
16687
|
+
performanceProfile: this.performanceProfile
|
|
16688
|
+
});
|
|
16638
16689
|
}
|
|
16639
16690
|
processResponsesFromConfig(dataTypes, method) {
|
|
16640
16691
|
return this.responseProcessor.processResponses(dataTypes, method);
|