@arrirpc/codegen-kotlin 0.74.0 → 0.75.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/dist/index.cjs +7 -6
- package/dist/index.mjs +8 -7
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
@@ -394,8 +394,9 @@ ${isLast ? "" : " hasProperties = true"}
|
|
394
394
|
override val ${kotlinIdentifier(context.discriminatorKey)} get() = "${context.discriminatorValue}"
|
395
395
|
`;
|
396
396
|
}
|
397
|
+
const hasProperties = fieldParts.length > 0;
|
397
398
|
const content = `${getCodeComment(schema.metadata, "", "class")}data class ${prefixedClassName}(
|
398
|
-
${fieldParts.join("\n")}
|
399
|
+
${fieldParts.join("\n")}${!hasProperties ? " private val placeholderKey: Short = 0" : ""}
|
399
400
|
) : ${implementedClass} {${discriminatorField}
|
400
401
|
override fun toJson(): String {
|
401
402
|
${toJsonParts.join("\n")}
|
@@ -426,7 +427,7 @@ ${defaultParts.join("\n")}
|
|
426
427
|
}
|
427
428
|
${fromJsonParts.join("\n")}
|
428
429
|
return ${prefixedClassName}(
|
429
|
-
${kotlinKeys.join(",\n ")}
|
430
|
+
${kotlinKeys.join(",\n ")}${hasProperties ? `,` : ""}
|
430
431
|
)
|
431
432
|
}
|
432
433
|
}
|
@@ -1151,8 +1152,8 @@ function kotlinProcedureFromSchema(schema, context) {
|
|
1151
1152
|
}
|
1152
1153
|
function kotlinHttpRpcFromSchema(schema, context) {
|
1153
1154
|
const name = getProcedureName(context);
|
1154
|
-
const params = schema.params ? kotlinClassName(`${context.typePrefix}_${schema.params}`) :
|
1155
|
-
const response = schema.response ? kotlinClassName(`${context.typePrefix}_${schema.response}`) :
|
1155
|
+
const params = schema.params ? kotlinClassName(`${context.typePrefix}_${schema.params}`) : void 0;
|
1156
|
+
const response = schema.response ? kotlinClassName(`${context.typePrefix}_${schema.response}`) : void 0;
|
1156
1157
|
const codeComment = getCodeComment(
|
1157
1158
|
{
|
1158
1159
|
description: schema.description,
|
@@ -1385,14 +1386,14 @@ function kotlinClientFromAppDefinition(def, options) {
|
|
1385
1386
|
}
|
1386
1387
|
}
|
1387
1388
|
if (procedureParts.length === 0) {
|
1388
|
-
return `${getHeader({ clientName, clientVersion: context.clientVersion
|
1389
|
+
return `${getHeader({ clientName, clientVersion: context.clientVersion})}
|
1389
1390
|
${getUtilityClasses(clientName)}
|
1390
1391
|
|
1391
1392
|
${modelParts.join("\n\n")}
|
1392
1393
|
|
1393
1394
|
${getUtilityFunctions(clientName)}`;
|
1394
1395
|
}
|
1395
|
-
return `${getHeader({ clientName, clientVersion: context.clientVersion
|
1396
|
+
return `${getHeader({ clientName, clientVersion: context.clientVersion})}
|
1396
1397
|
|
1397
1398
|
class ${clientName}(
|
1398
1399
|
private val httpClient: HttpClient,
|
package/dist/index.mjs
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import fs from 'node:fs';
|
2
|
-
import { removeDisallowedChars,
|
2
|
+
import { removeDisallowedChars, pascalCase, stringStartsWithNumber, camelCase, isServiceDefinition, isRpcDefinition, defineGeneratorPlugin, unflattenProcedures, isSchemaFormType, isSchemaFormEnum, isSchemaFormProperties, isSchemaFormElements, isSchemaFormValues, isSchemaFormDiscriminator, isSchemaFormRef } from '@arrirpc/codegen-utils';
|
3
3
|
|
4
4
|
const reservedIdentifierKeywords = [
|
5
5
|
"as",
|
@@ -388,8 +388,9 @@ ${isLast ? "" : " hasProperties = true"}
|
|
388
388
|
override val ${kotlinIdentifier(context.discriminatorKey)} get() = "${context.discriminatorValue}"
|
389
389
|
`;
|
390
390
|
}
|
391
|
+
const hasProperties = fieldParts.length > 0;
|
391
392
|
const content = `${getCodeComment(schema.metadata, "", "class")}data class ${prefixedClassName}(
|
392
|
-
${fieldParts.join("\n")}
|
393
|
+
${fieldParts.join("\n")}${!hasProperties ? " private val placeholderKey: Short = 0" : ""}
|
393
394
|
) : ${implementedClass} {${discriminatorField}
|
394
395
|
override fun toJson(): String {
|
395
396
|
${toJsonParts.join("\n")}
|
@@ -420,7 +421,7 @@ ${defaultParts.join("\n")}
|
|
420
421
|
}
|
421
422
|
${fromJsonParts.join("\n")}
|
422
423
|
return ${prefixedClassName}(
|
423
|
-
${kotlinKeys.join(",\n ")}
|
424
|
+
${kotlinKeys.join(",\n ")}${hasProperties ? `,` : ""}
|
424
425
|
)
|
425
426
|
}
|
426
427
|
}
|
@@ -1145,8 +1146,8 @@ function kotlinProcedureFromSchema(schema, context) {
|
|
1145
1146
|
}
|
1146
1147
|
function kotlinHttpRpcFromSchema(schema, context) {
|
1147
1148
|
const name = getProcedureName(context);
|
1148
|
-
const params = schema.params ? kotlinClassName(`${context.typePrefix}_${schema.params}`) :
|
1149
|
-
const response = schema.response ? kotlinClassName(`${context.typePrefix}_${schema.response}`) :
|
1149
|
+
const params = schema.params ? kotlinClassName(`${context.typePrefix}_${schema.params}`) : void 0;
|
1150
|
+
const response = schema.response ? kotlinClassName(`${context.typePrefix}_${schema.response}`) : void 0;
|
1150
1151
|
const codeComment = getCodeComment(
|
1151
1152
|
{
|
1152
1153
|
description: schema.description,
|
@@ -1379,14 +1380,14 @@ function kotlinClientFromAppDefinition(def, options) {
|
|
1379
1380
|
}
|
1380
1381
|
}
|
1381
1382
|
if (procedureParts.length === 0) {
|
1382
|
-
return `${getHeader({ clientName, clientVersion: context.clientVersion
|
1383
|
+
return `${getHeader({ clientName, clientVersion: context.clientVersion})}
|
1383
1384
|
${getUtilityClasses(clientName)}
|
1384
1385
|
|
1385
1386
|
${modelParts.join("\n\n")}
|
1386
1387
|
|
1387
1388
|
${getUtilityFunctions(clientName)}`;
|
1388
1389
|
}
|
1389
|
-
return `${getHeader({ clientName, clientVersion: context.clientVersion
|
1390
|
+
return `${getHeader({ clientName, clientVersion: context.clientVersion})}
|
1390
1391
|
|
1391
1392
|
class ${clientName}(
|
1392
1393
|
private val httpClient: HttpClient,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@arrirpc/codegen-kotlin",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.75.0",
|
4
4
|
"type": "module",
|
5
5
|
"license": "MIT",
|
6
6
|
"author": {
|
@@ -22,6 +22,6 @@
|
|
22
22
|
"dist"
|
23
23
|
],
|
24
24
|
"dependencies": {
|
25
|
-
"@arrirpc/codegen-utils": "0.
|
25
|
+
"@arrirpc/codegen-utils": "0.75.0"
|
26
26
|
}
|
27
27
|
}
|