OpenAPITools/openapi-generator · error · RuntimeException
This library currently only supports jackson serialization.
Error message
This library currently only supports jackson serialization. Try adding '--additional-properties serializationLibrary=jackson' to your command.
What it means
processJvmSpring — shared by the jvm-spring-webclient and jvm-spring-restclient libraries (KotlinClientCodegen.java:886, 896) — hard-requires serializationLibrary=jackson because the Spring stack templates are Jackson-based. Since the default serializationLibrary is moshi, selecting either Spring library without the explicit flag throws this RuntimeException.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java:875
additionalProperties.put(JVM, true);
additionalProperties.put(JVM_OKHTTP, true);
if (JVM_OKHTTP4.equals(getLibrary())) {
additionalProperties.put(JVM_OKHTTP4, true);
}
supportedLibraries.put(JVM_OKHTTP, "A workaround to use the same template folder for both 'jvm-okhttp3' and 'jvm-okhttp4'.");
setLibrary(JVM_OKHTTP);
// jvm specific supporting files
supportingFiles.add(new SupportingFile("infrastructure/Errors.kt.mustache", infrastructureFolder, "Errors.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ResponseExtensions.kt.mustache", infrastructureFolder, "ResponseExtensions.kt"));
supportingFiles.add(new SupportingFile("infrastructure/ApiResponse.kt.mustache", infrastructureFolder, "ApiResponse.kt"));
}
private void processJvmSpring(final String infrastructureFolder) {
if (getSerializationLibrary() != SERIALIZATION_LIBRARY_TYPE.jackson) {
throw new RuntimeException("This library currently only supports jackson serialization. Try adding '--additional-properties serializationLibrary=jackson' to your command.");
}
commonJvmMultiplatformSupportingFiles(infrastructureFolder);
addSupportingSerializerAdapters(infrastructureFolder);
additionalProperties.put(JVM_SPRING, true);
additionalProperties.put(JVM, true);
}
private void processJvmSpringWebClientLibrary(final String infrastructureFolder) {
processJvmSpring(infrastructureFolder);
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.");View on GitHub (pinned to fcec517be3)
Solutions
- Add `-p serializationLibrary=jackson` when using jvm-spring-webclient or jvm-spring-restclient.
- Remember the pairing rules: spring libraries ⇒ jackson; jvm-volley ⇒ gson; other libraries default to moshi.
Example fix
# before openapi-generator-cli generate -g kotlin --library=jvm-spring-webclient -i api.yaml # after openapi-generator-cli generate -g kotlin --library=jvm-spring-webclient -i api.yaml -p serializationLibrary=jackson
Defensive patterns
Strategy: validation
Validate before calling
# shell: spring libraries demand jackson
case "$LIBRARY" in
jvm-spring-webclient|jvm-spring-restclient)
[ "${SERIALIZATION_LIBRARY:-moshi}" = "jackson" ] || { echo "$LIBRARY requires serializationLibrary=jackson" >&2; exit 2; } ;;
esac Try / catch
try {
DefaultGenerator().opts(clientOptInput).generate()
} catch (e: RuntimeException) {
throw IllegalStateException("Spring library serialization mismatch: ${e.message}", e)
} Prevention
- Always set serializationLibrary=jackson when selecting a jvm-spring-* library.
- Do not reuse an okhttp4 (moshi) options line with a Spring library.
- Document the pairing: spring ⇒ jackson, volley ⇒ gson, others ⇒ moshi default.
When it happens
Trigger: `-g kotlin --library=jvm-spring-webclient` (default moshi → throw); `--library=jvm-spring-restclient -p serializationLibrary=gson|moshi|kotlinx_serialization`.
Common situations: Switching a kotlin client from okhttp4 (moshi default worked) to a Spring library by changing only --library; option presets that omit serializationLibrary.
Related errors
- {enumSerializationLibrary} is an invalid enum property namin
- useJackson3 requires serializationLibrary=jackson
- This library currently only supports gson serialization. Try
- useJackson3 is only available with Spring Boot >= 4
- Unexpected serializationLibrary value: {serializationLibrary
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/56e2d7a2d4e24ad0.
Report an issue: GitHub.