OpenAPITools/openapi-generator · error · RuntimeException
Multiplatform only supports string and kotlinx-datetime. Try
Error message
Multiplatform only supports string and kotlinx-datetime. Try adding '--additional-properties dateLibrary=kotlinx-datetime' to your command.
What it means
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.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java:905
additionalProperties.put(JVM_SPRING_WEBCLIENT, true);
}
private void processJvmSpringRestClientLibrary(final String infrastructureFolder) {
if (additionalProperties.getOrDefault(USE_SPRING_BOOT3, false).equals(false)
&& additionalProperties.getOrDefault(USE_SPRING_BOOT4, false).equals(false)) {
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.");
}
processJvmSpring(infrastructureFolder);
additionalProperties.put(JVM_SPRING_RESTCLIENT, true);
}
private void processMultiplatformLibrary(final String infrastructureFolder) {
commonJvmMultiplatformSupportingFiles(infrastructureFolder);
additionalProperties.put(MULTIPLATFORM, true);
if (!DateLibrary.STRING.value.equals(dateLibrary) && !DateLibrary.KOTLINX_DATETIME.value.equals(dateLibrary)) {
throw new RuntimeException("Multiplatform only supports string and kotlinx-datetime. Try adding '--additional-properties dateLibrary=kotlinx-datetime' to your command.");
}
setRequestDateConverter(RequestDateConverter.TO_STRING.value);
// multiplatform default includes
defaultIncludes.add("io.ktor.client.request.forms.InputProvider");
defaultIncludes.add(packageName + ".infrastructure.Base64ByteArray");
defaultIncludes.add(packageName + ".infrastructure.OctetByteArray");
// multiplatform type mapping
typeMapping.put("number", "kotlin.Double");
typeMapping.put("file", "OctetByteArray");
typeMapping.put("binary", "OctetByteArray");
typeMapping.put("ByteArray", "Base64ByteArray");
typeMapping.put("object", "kotlin.String"); // kotlin.Any not serializable
// multiplatform import mapping
importMapping.put("BigDecimal", "kotlin.Double");View on GitHub (pinned to fcec517be3)
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).
Example fix
# before openapi-generator-cli generate -g kotlin -i api.yaml \ --additional-properties library=multiplatform # after openapi-generator-cli generate -g kotlin -i api.yaml \ --additional-properties library=multiplatform,dateLibrary=kotlinx-datetime
Defensive patterns
Strategy: validation
Validate before calling
// before invoking the generator programmatically
String library = (String) opts.get("library");
String dateLibrary = (String) opts.getOrDefault("dateLibrary", "java8"); // kotlin default
if ("multiplatform".equals(library)
&& !("string".equals(dateLibrary) || "kotlinx-datetime".equals(dateLibrary))) {
throw new IllegalArgumentException(
"library=multiplatform requires dateLibrary=string or kotlinx-datetime");
} Try / catch
try {
new DefaultGenerator().opts(clientOptInput).generate();
} catch (RuntimeException e) {
// message contains the exact --additional-properties fix to suggest to the user
throw new BuildException("openapi-generator config rejected: " + e.getMessage(), e);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- The [%s] Documentation Provider is not supported by this gen
- The Annotation Library [%s] is not supported by this generat
- The [%s] documentation provider does not support [%s] as com
- Currently, reactive option doesn't supported by Spring Cloud
- Additional property 'useFlowForArrayReturnType' must be set
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/1c58f8432e53736c.
Report an issue: GitHub.