{"record":{"id":"4c6ce7906da0ff17","repo":"OpenAPITools/openapi-generator","slug":"clientregistrationid-requires-usespringboot4-true","errorCode":null,"errorMessage":"clientRegistrationId requires useSpringBoot4=true because @ClientRegistrationId is provided by Spring Security 7","messagePattern":"clientRegistrationId requires useSpringBoot4=true because @ClientRegistrationId is provided by Spring Security 7","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java","lineNumber":653,"sourceCode":"        convertPropertyToBooleanAndWriteBack(USE_SPRING_SECURITY_PRE_AUTHORIZE, this::setUseSpringSecurityPreAuthorize);\n        convertPropertyToStringAndWriteBack(SPRING_SECURITY_AUTHORITY_PREFIX, this::setSpringSecurityAuthorityPrefix);\n\n        additionalProperties.put(\"springHttpStatus\", new SpringHttpStatusLambda());\n\n        convertPropertyToBooleanAndWriteBack(USE_ENUM_CASE_INSENSITIVE, this::setUseEnumCaseInsensitive);\n        convertPropertyToBooleanAndWriteBack(USE_JACKSON_3, this::setUseJackson3);\n        convertPropertyToBooleanAndWriteBack(USE_SPRING_BOOT3, this::setUseSpringBoot3);\n        convertPropertyToBooleanAndWriteBack(USE_SPRING_BOOT4, this::setUseSpringBoot4);\n\n        if (isUseSpringBoot4()) {\n            setUseSpringBoot3(false);\n        }\n        if (isNotEmpty(clientRegistrationId)) {\n            if (!SPRING_HTTP_INTERFACE.equals(library)) {\n                throw new IllegalArgumentException(CLIENT_REGISTRATION_ID + \" is only supported with the \" + SPRING_HTTP_INTERFACE + \" library\");\n            }\n            if (!isUseSpringBoot4()) {\n                throw new IllegalArgumentException(CLIENT_REGISTRATION_ID + \" requires \" + USE_SPRING_BOOT4 + \"=true because @ClientRegistrationId is provided by Spring Security 7\");\n            }\n        }\n        if (useSpringSecurityPreAuthorize && !SPRING_BOOT.equals(library)) {\n            throw new IllegalArgumentException(USE_SPRING_SECURITY_PRE_AUTHORIZE\n                    + \" is only supported with the \" + SPRING_BOOT + \" library\");\n        }\n\n        if (isUseSpringBoot3() || isUseSpringBoot4()) {\n            if (AnnotationLibrary.SWAGGER1.equals(getAnnotationLibrary())) {\n                throw new IllegalArgumentException(AnnotationLibrary.SWAGGER1.getPropertyName() + \" is not supported with Spring Boot > 3.x\");\n            }\n            useJakartaEe = true;\n            applyJakartaPackage();\n        }\n        if(isUseJackson3() && !isUseSpringBoot4()){\n            throw new IllegalArgumentException(\"useJackson3 is only available with Spring Boot >= 4\");\n        }\n        if(this.useJackson3){","sourceCodeStart":635,"sourceCodeEnd":671,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java#L635-L671","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","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."],"exampleFix":"# before\nopenapi-generator generate -g spring -i api.yaml --library=spring-http-interface -DclientRegistrationId=okta\n\n# after\nopenapi-generator generate -g spring -i api.yaml --library=spring-http-interface -DclientRegistrationId=okta -DuseSpringBoot4=true","handlingStrategy":"validation","validationCode":"# bash: assert option pairing before invoking the generator\nif [ -n \"$CLIENT_REGISTRATION_ID\" ] && [ \"$USE_SPRING_BOOT4\" != \"true\" ]; then\n  echo \"clientRegistrationId requires useSpringBoot4=true\" >&2; exit 1\nfi\nopenapi-generator generate -g spring --library=spring-http-interface \\\n  -DclientRegistrationId=$CLIENT_REGISTRATION_ID -DuseSpringBoot4=$USE_SPRING_BOOT4","typeGuard":null,"tryCatchPattern":"// Java (programmatic use)\ntry {\n    opts.put(\"clientRegistrationId\", \"okta\");\n    opts.put(\"useSpringBoot4\", true);\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (IllegalArgumentException e) {\n    // option-conflict messages from processOpts(); log and fix config, do not retry\n    throw new GenerationConfigException(\"Invalid spring options: \" + e.getMessage(), e);\n}","preventionTips":["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."],"tags":["spring","configuration","oauth2","openapi-generator"],"backgroundTag":"incompatible-generator-options","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}