@accelbyte/codegen 2.0.0-beta.4 → 2.0.0-beta.5
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.
|
@@ -594,7 +594,9 @@ class ParserUtils {
|
|
|
594
594
|
${content}`;
|
|
595
595
|
};
|
|
596
596
|
static sortPathParamsByPath = (pathParams, path2) => {
|
|
597
|
-
|
|
597
|
+
const params = path2.match(/{\w*}/g) || [];
|
|
598
|
+
const cleanParams = params.map((param) => param.replace("{", "").replace("}", ""));
|
|
599
|
+
return pathParams.sort((a, b) => cleanParams.indexOf(a.name) - cleanParams.indexOf(b.name));
|
|
598
600
|
};
|
|
599
601
|
}
|
|
600
602
|
const mappedMethod = (httpMethod, isForm) => {
|
|
@@ -1281,6 +1283,7 @@ class CodeGenerator {
|
|
|
1281
1283
|
continue;
|
|
1282
1284
|
}
|
|
1283
1285
|
const [tag] = endpoint.tags;
|
|
1286
|
+
const pathWithBase = `${api.basePath ?? ""}${path2}`;
|
|
1284
1287
|
mapClassMethods[tag] = mapClassMethods[tag] ? mapClassMethods[tag] : {};
|
|
1285
1288
|
const isForm = endpoint.consumes && endpoint.consumes[0] === "application/x-www-form-urlencoded";
|
|
1286
1289
|
const classMethod = ParserUtils.generateNaturalLangMethod({
|
|
@@ -1291,7 +1294,7 @@ class CodeGenerator {
|
|
|
1291
1294
|
existingMethods: mapClassMethods[tag]
|
|
1292
1295
|
});
|
|
1293
1296
|
mapClassMethods[tag][classMethod] = `${path2} ${httpMethod}`;
|
|
1294
|
-
snippetMap[
|
|
1297
|
+
snippetMap[pathWithBase] = snippetMap[pathWithBase] ? snippetMap[pathWithBase] : {};
|
|
1295
1298
|
let description = endpoint.description;
|
|
1296
1299
|
description = description || "";
|
|
1297
1300
|
description = description.replace(/\s+/g, " ");
|
|
@@ -1306,7 +1309,6 @@ class CodeGenerator {
|
|
|
1306
1309
|
arrayDefinitions.push(responseClass);
|
|
1307
1310
|
}
|
|
1308
1311
|
const queryParams = ParserUtils.filterQueryParameters(endpoint.parameters);
|
|
1309
|
-
const pathWithBase = `${api.basePath ?? ""}${path2}`;
|
|
1310
1312
|
const isFormUrlEncoded = ParserUtils.isFormUrlEncoded(httpMethod, endpoint.consumes);
|
|
1311
1313
|
const pathParams = ParserUtils.filterPathParams(endpoint.parameters);
|
|
1312
1314
|
let bodyParams = ParserUtils.filterBodyParams(endpoint.parameters);
|
|
@@ -1349,7 +1351,7 @@ class CodeGenerator {
|
|
|
1349
1351
|
const serviceNameTitle = ParserUtils.convertDashesToTitleCase(serviceName);
|
|
1350
1352
|
const { apiGenName } = ParserUtils.generateApiName(tag);
|
|
1351
1353
|
const resultSnippet = templateSdkSnippet(serviceNameTitle, apiGenName, snippetMethod);
|
|
1352
|
-
snippetMap[
|
|
1354
|
+
snippetMap[pathWithBase][httpMethod] = {
|
|
1353
1355
|
web: resultSnippet,
|
|
1354
1356
|
webGit: GIT_URL + `/sdk-${serviceName}/src/generated-public/${serviceName}/${apiGenName}.ts`,
|
|
1355
1357
|
shell: snippetShell
|