OpenAPITools/openapi-generator · error · IllegalArgumentException

clientRegistrationId is only supported with the spring-http-

Error message

clientRegistrationId is only supported with the spring-http-interface library

What it means

In the spring generator, clientRegistrationId (an OAuth2 client registration injected via @ClientRegistrationId, provided by Spring Security 7) is only implemented for the spring-http-interface library and requires useSpringBoot4=true. Setting clientRegistrationId with any other library throws IllegalArgumentException immediately; even with spring-http-interface it throws again unless Boot 4 is enabled.

Source

Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java:650

        convertPropertyToBooleanAndWriteBack(USE_SPRING_BUILT_IN_VALIDATION, this::setUseSpringBuiltInValidation);
        convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_DEDUCTION_FOR_ONE_OF_INTERFACES, this::setUseDeductionForOneOfInterfaces);
        convertPropertyToStringAndWriteBack(CLIENT_REGISTRATION_ID, this::setClientRegistrationId);
        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()){

View on GitHub (pinned to fcec517be3)

Solutions

  1. Remove clientRegistrationId if you do not use spring-http-interface with Boot 4
  2. Or enable the full supported combination: -l spring-http-interface -c useSpringBoot4=true -c clientRegistrationId=my-client
  3. Note the second constraint: @ClientRegistrationId comes from Spring Security 7, which ships with Boot 4, so Boot 3 projects cannot use this option at all
  4. For Boot 3 + OAuth2, keep clientRegistrationId out of generation and register the client in application.yml instead

Example fix

# before
openapi-generator-cli generate -i api.yaml -g spring -c clientRegistrationId=orders-api
# after
openapi-generator-cli generate -i api.yaml -g spring -l spring-http-interface -c useSpringBoot4=true -c clientRegistrationId=orders-api
Defensive patterns

Strategy: validation

Validate before calling

# bash: enforce the clientRegistrationId constraints up front
if [[ -n "${CLIENT_REGISTRATION_ID:-}" ]]; then
  [[ "${LIBRARY:-}" == spring-http-interface && "${USE_SPRING_BOOT4:-false}" == true ]] \
    || { echo 'clientRegistrationId requires -l spring-http-interface and useSpringBoot4=true'; exit 1; }
fi

Try / catch

try {
    SpringCodegen codegen = new SpringCodegen();
    codegen.setLibrary("spring-http-interface");
    codegen.additionalProperties().put("useSpringBoot4", "true");
    codegen.setClientRegistrationId("orders-api");
    new DefaultGenerator().opts(new ClientOptInput().opts(codegen)).generate();
} catch (IllegalArgumentException e) {
    // names the exact constraint: wrong library, or missing useSpringBoot4=true
}

Prevention

When it happens

Trigger: -g spring -c clientRegistrationId=my-client with the default library; or -l spring-http-interface -c clientRegistrationId=my-client without -c useSpringBoot4=true. The check runs in processOpts() before generation.

Common situations: Adding OAuth2 client registration to an existing spring template/preset that uses spring-boot or spring-cloud; copying the option from Spring Security docs into a Boot 3 project; enabling the option company-wide while libraries differ per service.

Related errors


AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22). Data as JSON: /api/errors/00c944f205fb6795. Report an issue: GitHub.