{"record":{"id":"1c58f8432e53736c","repo":"OpenAPITools/openapi-generator","slug":"multiplatform-only-supports-string-and-kotlinx-dat","errorCode":null,"errorMessage":"Multiplatform only supports string and kotlinx-datetime. Try adding '--additional-properties dateLibrary=kotlinx-datetime' to your command.","messagePattern":"Multiplatform only supports string and kotlinx-datetime\\. Try adding '--additional-properties dateLibrary=kotlinx-datetime' to your command\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java","lineNumber":905,"sourceCode":"        additionalProperties.put(JVM_SPRING_WEBCLIENT, true);\n    }\n\n    private void processJvmSpringRestClientLibrary(final String infrastructureFolder) {\n        if (additionalProperties.getOrDefault(USE_SPRING_BOOT3, false).equals(false)\n                && additionalProperties.getOrDefault(USE_SPRING_BOOT4, false).equals(false)) {\n            throw new RuntimeException(\"This library requires Spring Boot 3 or 4. Try adding '--additional-properties useSpringBoot3=true' or '--additional-properties useSpringBoot4=true' to your command.\");\n        }\n\n        processJvmSpring(infrastructureFolder);\n        additionalProperties.put(JVM_SPRING_RESTCLIENT, true);\n    }\n\n    private void processMultiplatformLibrary(final String infrastructureFolder) {\n        commonJvmMultiplatformSupportingFiles(infrastructureFolder);\n        additionalProperties.put(MULTIPLATFORM, true);\n\n        if (!DateLibrary.STRING.value.equals(dateLibrary) && !DateLibrary.KOTLINX_DATETIME.value.equals(dateLibrary)) {\n            throw new RuntimeException(\"Multiplatform only supports string and kotlinx-datetime. Try adding '--additional-properties dateLibrary=kotlinx-datetime' to your command.\");\n        }\n\n        setRequestDateConverter(RequestDateConverter.TO_STRING.value);\n\n        // multiplatform default includes\n        defaultIncludes.add(\"io.ktor.client.request.forms.InputProvider\");\n        defaultIncludes.add(packageName + \".infrastructure.Base64ByteArray\");\n        defaultIncludes.add(packageName + \".infrastructure.OctetByteArray\");\n\n        // multiplatform type mapping\n        typeMapping.put(\"number\", \"kotlin.Double\");\n        typeMapping.put(\"file\", \"OctetByteArray\");\n        typeMapping.put(\"binary\", \"OctetByteArray\");\n        typeMapping.put(\"ByteArray\", \"Base64ByteArray\");\n        typeMapping.put(\"object\", \"kotlin.String\");  // kotlin.Any not serializable\n\n        // multiplatform import mapping\n        importMapping.put(\"BigDecimal\", \"kotlin.Double\");","sourceCodeStart":887,"sourceCodeEnd":923,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java#L887-L923","documentation":"The Kotlin client generator's 'multiplatform' library produces common Kotlin code shared across JVM/JS/native targets, and common code cannot use JVM-only date types. processMultiplatformLibrary() therefore accepts only the 'string' and 'kotlinx-datetime' date libraries and throws a RuntimeException for anything else. The Kotlin client's default dateLibrary is 'java8', so the error fires during option processing unless dateLibrary is changed explicitly.","triggerScenarios":"Running `openapi-generator-cli generate -g kotlin` with `--additional-properties library=multiplatform` while dateLibrary is left at its default (java8) or explicitly set to java8/threetenbp/rx (any value other than string/kotlinx-datetime). The check at KotlinClientCodegen.java:905 runs during processMultiplatformLibrary() after `library=multiplatform` is selected.","commonSituations":"Switching an existing kotlin client configuration to Kotlin Multiplatform (e.g. for a Kotlin/JS or KMP app) without touching the date options; reusing CI generator flags from a JVM-only kotlin project after a version upgrade; copy-pasting examples that pair library=multiplatform with the default java8 dates.","solutions":["Add `--additional-properties dateLibrary=kotlinx-datetime` to the same command that sets `library=multiplatform` (this is exactly what the message suggests).","Alternatively use `--additional-properties dateLibrary=string` if you want to serialize dates as plain strings with no datetime dependency.","If you actually need java8/threetenbp dates, drop `library=multiplatform` and use the default JVM client (e.g. library=jvm or the default kotlin client)."],"exampleFix":"# before\nopenapi-generator-cli generate -g kotlin -i api.yaml \\\n  --additional-properties library=multiplatform\n# after\nopenapi-generator-cli generate -g kotlin -i api.yaml \\\n  --additional-properties library=multiplatform,dateLibrary=kotlinx-datetime","handlingStrategy":"validation","validationCode":"// before invoking the generator programmatically\nString library = (String) opts.get(\"library\");\nString dateLibrary = (String) opts.getOrDefault(\"dateLibrary\", \"java8\"); // kotlin default\nif (\"multiplatform\".equals(library)\n        && !(\"string\".equals(dateLibrary) || \"kotlinx-datetime\".equals(dateLibrary))) {\n    throw new IllegalArgumentException(\n        \"library=multiplatform requires dateLibrary=string or kotlinx-datetime\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (RuntimeException e) {\n    // message contains the exact --additional-properties fix to suggest to the user\n    throw new BuildException(\"openapi-generator config rejected: \" + e.getMessage(), e);\n}","preventionTips":["Treat library= and dateLibrary= as one coupled choice for kotlin; change them together.","Keep generator invocations in a single scripted location so option pairs cannot drift.","After upgrading openapi-generator, re-run generation in CI to catch newly-validated option constraints."],"tags":["kotlin","multiplatform","date-library","additional-properties","openapi-generator","config-validation"],"backgroundTag":"unsupported-option-value","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}