OpenAPITools/openapi-generator · error · IllegalArgumentException
clientRegistrationId requires useSpringBoot4=true because…
Error message
clientRegistrationId requires useSpringBoot4=true because @ClientRegistrationId is provided by Spring Security 7
What it means
Thrown by the Spring generator's option processing when clientRegistrationId is set but useSpringBoot4 is not enabled. The generated HTTP-interface client code relies on @ClientRegistrationId, an annotation introduced with Spring Security 7, which ships only with Spring Boot 4. The generator refuses to emit code that would not compile against older Spring Boot versions.
Solutions
- Add -DuseSpringBoot4=true (or <useSpringBoot4>true</useSpringBoot4> in the Maven/Gradle plugin config) whenever clientRegistrationId is set.
- Keep --library=spring-http-interface; clientRegistrationId is rejected by every other library.
- If you must stay on Spring Boot 3, remove clientRegistrationId and register the OAuth2 ClientRegistration in your own Spring configuration.
Example fix
# before openapi-generator generate -g spring -i api.yaml --library=spring-http-interface -DclientRegistrationId=okta # after openapi-generator generate -g spring -i api.yaml --library=spring-http-interface -DclientRegistrationId=okta -DuseSpringBoot4=true
Defensive patterns
Strategy: validation
Validate before calling
# bash: assert option pairing before invoking the generator if [ -n "$CLIENT_REGISTRATION_ID" ] && [ "$USE_SPRING_BOOT4" != "true" ]; then echo "clientRegistrationId requires useSpringBoot4=true" >&2; exit 1 fi openapi-generator generate -g spring --library=spring-http-interface \ -DclientRegistrationId=$CLIENT_REGISTRATION_ID -DuseSpringBoot4=$USE_SPRING_BOOT4
Try / catch
// Java (programmatic use)
try {
opts.put("clientRegistrationId", "okta");
opts.put("useSpringBoot4", true);
new DefaultGenerator().opts(clientOptInput).generate();
} catch (IllegalArgumentException e) {
// option-conflict messages from processOpts(); log and fix config, do not retry
throw new GenerationConfigException("Invalid spring options: " + e.getMessage(), e);
} Prevention
- Keep one versioned, reviewed generator options file per project instead of ad-hoc CLI flags.
- Treat clientRegistrationId as a Boot-4-only feature and document it next to the option.
- Fail fast in CI: run generation on every spec change so option conflicts surface immediately.
When it happens
Trigger: Run openapi-generator (CLI, Maven or Gradle plugin) with -g spring, --library=spring-http-interface and -DclientRegistrationId=<id> but without -DuseSpringBoot4=true. This specific message appears only after the library check passed, i.e. library is spring-http-interface.
Common situations: Copying an OAuth2 client example that predates Spring Boot 4 support; enabling clientRegistrationId while keeping Boot 3 defaults; setting useSpringBoot3=true together with clientRegistrationId (the generator silently clears useSpringBoot3 when useSpringBoot4 is on, but not the reverse).
Related errors
- clientRegistrationId is only supported with the…
- Currently, reactive option doesn't supported by Spring Cloud
- Library 'spring-http-interface' is only supported with…
- swagger1AnnotationLibrary is not supported with Spring Boot…
- This library currently only supports jackson serialization…
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/4c6ce7906da0ff17.
Report an issue: GitHub.
Appendix: source
Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java:653
convertPropertyToBooleanAndWriteBack(USE_SPRING_SECURITY_PRE_AUTHORIZE, this::setUseSpringSecurityPreAuthorize);
convertPropertyToStringAndWriteBack(SPRING_SECURITY_AUTHORITY_PREFIX, this::setSpringSecurityAuthorityPrefix);
additionalProperties.put("springHttpStatus", new SpringHttpStatusLambda());
convertPropertyToBooleanAndWriteBack(USE_ENUM_CASE_INSENSITIVE, this::setUseEnumCaseInsensitive);
convertPropertyToBooleanAndWriteBack(USE_JACKSON_3, this::setUseJackson3);
convertPropertyToBooleanAndWriteBack(USE_SPRING_BOOT3, this::setUseSpringBoot3);
convertPropertyToBooleanAndWriteBack(USE_SPRING_BOOT4, this::setUseSpringBoot4);
if (isUseSpringBoot4()) {
setUseSpringBoot3(false);
}
if (isNotEmpty(clientRegistrationId)) {
if (!SPRING_HTTP_INTERFACE.equals(library)) {
throw new IllegalArgumentException(CLIENT_REGISTRATION_ID + " is only supported with the " + SPRING_HTTP_INTERFACE + " library");
}
if (!isUseSpringBoot4()) {
throw new IllegalArgumentException(CLIENT_REGISTRATION_ID + " requires " + USE_SPRING_BOOT4 + "=true because @ClientRegistrationId is provided by Spring Security 7");
}
}
if (useSpringSecurityPreAuthorize && !SPRING_BOOT.equals(library)) {
throw new IllegalArgumentException(USE_SPRING_SECURITY_PRE_AUTHORIZE
+ " is only supported with the " + SPRING_BOOT + " library");
}
if (isUseSpringBoot3() || isUseSpringBoot4()) {
if (AnnotationLibrary.SWAGGER1.equals(getAnnotationLibrary())) {
throw new IllegalArgumentException(AnnotationLibrary.SWAGGER1.getPropertyName() + " is not supported with Spring Boot > 3.x");
}
useJakartaEe = true;
applyJakartaPackage();
}
if(isUseJackson3() && !isUseSpringBoot4()){
throw new IllegalArgumentException("useJackson3 is only available with Spring Boot >= 4");
}
if(this.useJackson3){View on GitHub (pinned to fcec517be3)