OpenAPITools/openapi-generator · error · IllegalArgumentException
useJackson3 is only supported for the jvm-okhttp4 and jvm-sp
Error message
useJackson3 is only supported for the jvm-okhttp4 and jvm-spring-restclient libraries at this time.
What it means
The useJackson3 codegen paths only exist for two libraries: jvm-okhttp4 and jvm-spring-restclient. The check compares getLibrary() against exactly those two constants; with any other --library value (jvm-ktor, jvm-okhttp/jvm-okhttp3, jvm-retrofit2, jvm-volley, jvm-vertx, multiplatform, and notably jvm-spring-webclient) it throws IllegalArgumentException.
Source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java:501
}
if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {
setSerializationLibrary((String) additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY));
additionalProperties.put(this.serializationLibrary.name(), true);
} else {
additionalProperties.put(this.serializationLibrary.name(), true);
}
if (isUseJackson3()) {
if (this.serializationLibrary != SERIALIZATION_LIBRARY_TYPE.jackson) {
throw new IllegalArgumentException("useJackson3 requires serializationLibrary=jackson");
}
if (additionalProperties.containsKey("openApiNullable")
&& Boolean.parseBoolean(additionalProperties.get("openApiNullable").toString())) {
throw new IllegalArgumentException("openApiNullable cannot be set with useJackson3");
}
if (!JVM_OKHTTP4.equals(getLibrary()) && !JVM_SPRING_RESTCLIENT.equals(getLibrary())) {
throw new IllegalArgumentException("useJackson3 is only supported for the jvm-okhttp4 and jvm-spring-restclient libraries at this time.");
}
if (JVM_SPRING_RESTCLIENT.equals(getLibrary()) && !useSpringBoot4) {
throw new IllegalArgumentException("useJackson3 with jvm-spring-restclient requires useSpringBoot4=true.");
}
}
if (additionalProperties.containsKey(MAP_FILE_BINARY_TO_BYTE_ARRAY)) {
setMapFileBinaryToByteArray(convertPropertyToBooleanAndWriteBack(MAP_FILE_BINARY_TO_BYTE_ARRAY));
}
additionalProperties.put(MAP_FILE_BINARY_TO_BYTE_ARRAY, mapFileBinaryToByteArray);
if (mapFileBinaryToByteArray) {
typeMapping.put("file", "kotlin.ByteArray");
typeMapping.put("binary", "kotlin.ByteArray");
}
if (additionalProperties.containsKey(GENERATE_ONEOF_ANYOF_WRAPPERS)) {
setGenerateOneOfAnyOfWrappers(convertPropertyToBooleanAndWriteBack(GENERATE_ONEOF_ANYOF_WRAPPERS));
}View on GitHub (pinned to fcec517be3)
Solutions
- Switch `--library` to `jvm-okhttp4` or `jvm-spring-restclient` if you need Jackson 3.
- Or drop `useJackson3` and stay on Jackson 2 for the current library.
- Use the exact strings 'jvm-okhttp4' and 'jvm-spring-restclient' — close spellings silently pick a different library or fail.
Example fix
# before openapi-generator-cli generate -g kotlin --library=jvm-spring-webclient -i api.yaml -p useJackson3=true # after openapi-generator-cli generate -g kotlin --library=jvm-spring-restclient -i api.yaml -p useJackson3=true
Defensive patterns
Strategy: validation
Validate before calling
# shell: gate useJackson3 on the two supported libraries
if [ "$USE_JACKSON_3" = "true" ]; then
case "$LIBRARY" in
jvm-okhttp4|jvm-spring-restclient) ;;
*) echo "useJackson3 only supports jvm-okhttp4 / jvm-spring-restclient, got library: $LIBRARY" >&2; exit 2 ;;
esac
fi Type guard
// Kotlin
val JACKSON3_LIBRARIES = setOf("jvm-okhttp4", "jvm-spring-restclient")
fun supportsJackson3(library: String?): Boolean = library in JACKSON3_LIBRARIES Try / catch
try {
DefaultGenerator().opts(clientOptInput).generate()
} catch (e: IllegalArgumentException) {
throw IllegalStateException("useJackson3 unsupported for the selected library: ${e.message}", e)
} Prevention
- Check library strings against the exact constants jvm-okhttp4 / jvm-spring-restclient.
- Remember jvm-spring-webclient is NOT Jackson-3-capable — only restclient is.
- Prefer staying on Jackson 2 unless you specifically need tools.jackson packages.
When it happens
Trigger: `-g kotlin --library=jvm-ktor -p useJackson3=true`; `--library=jvm-spring-webclient -p useJackson3=true` (webclient is NOT in the allowlist — only restclient); `--library=jvm-retrofit2 -p useJackson3=true`.
Common situations: Assuming 'jvm-spring-webclient' counts as a Spring library for Jackson 3; retrofit2 users wanting to modernize to Jackson 3; option presets shared across different --library values.
Related errors
- useJackson3 requires serializationLibrary=jackson
- openApiNullable cannot be set with useJackson3
- useJackson3 with jvm-spring-restclient requires useSpringBoo
- useJackson3 is only supported for the 'native', 'apache-http
- Unexpected serializationLibrary value: {serializationLibrary
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/38369a7fa15be6f8.
Report an issue: GitHub.