@accelbyte/codegen 0.0.0-dev-20260326093546 → 0.0.0-dev-20260406042959
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.
|
@@ -197,7 +197,8 @@ var getResponseType = ({
|
|
|
197
197
|
defaultType = "unknown"
|
|
198
198
|
}) => {
|
|
199
199
|
const responseClass = responseClasses.length === 1 ? responseClasses?.[0] : "unknown";
|
|
200
|
-
const
|
|
200
|
+
const rawResponseType = responseClass !== "unknown" ? responseClasses?.[0] : defaultType;
|
|
201
|
+
const responseType = rawResponseType === "__dictionary__" ? "Record<string, any>" : rawResponseType;
|
|
201
202
|
return {
|
|
202
203
|
responseType,
|
|
203
204
|
responseTypeInAxiosResponse: `Promise<AxiosResponse<${responseType}>>`,
|
|
@@ -517,13 +518,14 @@ var ParserUtils = class _ParserUtils {
|
|
|
517
518
|
};
|
|
518
519
|
static parseRefImport = (bodyParam) => {
|
|
519
520
|
const $ref = bodyParam?.schema?.$ref || bodyParam?.schema?.items?.$ref;
|
|
520
|
-
if (!$ref) {
|
|
521
|
+
if (!$ref || $ref.endsWith("__dictionary__")) {
|
|
521
522
|
return null;
|
|
522
523
|
}
|
|
523
524
|
const type = _ParserUtils.parseRefType($ref);
|
|
524
525
|
return `import { ${type} } from '../../generated-definitions/${type}.js'`;
|
|
525
526
|
};
|
|
526
527
|
static parseRefType = ($ref) => {
|
|
528
|
+
if ($ref.endsWith("__dictionary__")) return "__dictionary__";
|
|
527
529
|
let ref = $ref.replace(".", "/");
|
|
528
530
|
if (ref[ref.length - 1] === "." || ref[ref.length - 1] === "/") {
|
|
529
531
|
ref = ref.slice(0, -1);
|
|
@@ -1096,6 +1098,7 @@ var templateMethod = ({
|
|
|
1096
1098
|
let dataType = null;
|
|
1097
1099
|
if (httpMethod !== "get") {
|
|
1098
1100
|
dataType = ParserUtils.parseBodyParamsType(bodyParams);
|
|
1101
|
+
if (dataType === "__dictionary__") dataType = "Record<string, any>";
|
|
1099
1102
|
importStatements = ParserUtils.parseBodyParamsImports(bodyParams);
|
|
1100
1103
|
methodParams += dataType ? `data: ${dataType},` : "";
|
|
1101
1104
|
methodParamsNoTypes += dataType ? `data,` : "";
|
|
@@ -1119,7 +1122,7 @@ var templateMethod = ({
|
|
|
1119
1122
|
}
|
|
1120
1123
|
const isFileUpload = methodParams.indexOf("data: {file") > -1;
|
|
1121
1124
|
const { responseType, responseTypeInResponse } = getResponseType({ responseClasses });
|
|
1122
|
-
const resolvedResponseClassValidated = responseType !== "unknown" ? `${responseType}` : "z.unknown()";
|
|
1125
|
+
const resolvedResponseClassValidated = responseClasses.length === 1 && responseClasses[0] === "__dictionary__" ? "z.record(z.string(), z.any())" : responseType !== "unknown" ? `${responseType}` : "z.unknown()";
|
|
1123
1126
|
methodParams = (queryParamsType ? `${methodParams} ${queryParamsType}` : methodParams).replace(/,\s*$/, "");
|
|
1124
1127
|
methodParamsNoTypes = queryParamsType ? `${methodParamsNoTypes} queryParams` : methodParamsNoTypes;
|
|
1125
1128
|
const isGuardInvoked = ["get", "post", "put", "patch", "delete"].includes(httpMethod);
|
|
@@ -1463,7 +1466,7 @@ var SwaggerReaderHelpers = class _SwaggerReaderHelpers {
|
|
|
1463
1466
|
const responseClass = responseClasses.length > 1 ? null : responseClasses?.[0];
|
|
1464
1467
|
const { className, classGenName } = ParserUtils.generateClassName(tag, isAdminEndpoint);
|
|
1465
1468
|
tagToClassImportsRecord[className] = tagToClassImportsRecord[className] ? tagToClassImportsRecord[className] : {};
|
|
1466
|
-
if (responseClass) {
|
|
1469
|
+
if (responseClass && responseClass !== "__dictionary__") {
|
|
1467
1470
|
tagToClassImportsRecord[className][responseClass] = `import { ${responseClass} } from '../../generated-definitions/${responseClass}.js'`;
|
|
1468
1471
|
}
|
|
1469
1472
|
if (responseClass && responseClass.endsWith("Array")) {
|
|
@@ -1711,7 +1714,14 @@ ${exportedTypeString}
|
|
|
1711
1714
|
};
|
|
1712
1715
|
} else if (type) {
|
|
1713
1716
|
if (type === "object" && definition.additionalProperties) {
|
|
1714
|
-
const
|
|
1717
|
+
const additionalProps = definition.additionalProperties;
|
|
1718
|
+
if (Object.keys(additionalProps).length === 0) {
|
|
1719
|
+
return {
|
|
1720
|
+
schemaString: `${schemaAttribute} z.record(z.any())${schemaRequired}`,
|
|
1721
|
+
typeString: `${typeAttribute} Record<string, any>${typeNullishability}`
|
|
1722
|
+
};
|
|
1723
|
+
}
|
|
1724
|
+
const zodAttribute = this.parseToZodAttribute("", additionalProps, [""]);
|
|
1715
1725
|
return {
|
|
1716
1726
|
schemaString: `${schemaAttribute} z.record(${zodAttribute.schemaString})${schemaRequired}`,
|
|
1717
1727
|
typeString: `${typeAttribute} Record<string, ${zodAttribute.typeString}>${typeNullishability}`
|
|
@@ -1992,6 +2002,7 @@ var CodeGenerator = class _CodeGenerator {
|
|
|
1992
2002
|
const duplicates = /* @__PURE__ */ new Map();
|
|
1993
2003
|
const definitions = api2?.components?.schemas || api2.definitions;
|
|
1994
2004
|
for (const ref in definitions) {
|
|
2005
|
+
if (ref === "__dictionary__") continue;
|
|
1995
2006
|
const definition = definitions[ref];
|
|
1996
2007
|
const fileName = ParserUtils.parseRefType(ref);
|
|
1997
2008
|
const fileExist = import_fs5.default.existsSync(import_path4.default.join(DIST_DEFINITION_DIR, `${fileName}.ts`));
|
|
@@ -2047,6 +2058,7 @@ var SwaggerDownloader = class _SwaggerDownloader {
|
|
|
2047
2058
|
fs6.readFile(filePath, "utf8", (err, data) => {
|
|
2048
2059
|
if (err) throw err;
|
|
2049
2060
|
let result = data;
|
|
2061
|
+
result = result.replace(new RegExp("map%5Bstring%5Dinterface%20%7B%7D", "g"), "__dictionary__").replace(new RegExp("map\\[string\\]interface \\{\\}", "g"), "__dictionary__").replace(new RegExp("map\\[string\\]any", "g"), "__dictionary__");
|
|
2050
2062
|
searchStr.forEach((s) => {
|
|
2051
2063
|
result = result.replace(new RegExp(s, "g"), " ");
|
|
2052
2064
|
});
|