{"record":{"id":"00c944f205fb6795","repo":"OpenAPITools/openapi-generator","slug":"clientregistrationid-is-only-supported-with-the-sp","errorCode":null,"errorMessage":"clientRegistrationId is only supported with the spring-http-interface library","messagePattern":"clientRegistrationId is only supported with the spring-http-interface library","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java","lineNumber":650,"sourceCode":"        convertPropertyToBooleanAndWriteBack(USE_SPRING_BUILT_IN_VALIDATION, this::setUseSpringBuiltInValidation);\n        convertPropertyToBooleanAndWriteBack(CodegenConstants.USE_DEDUCTION_FOR_ONE_OF_INTERFACES, this::setUseDeductionForOneOfInterfaces);\n        convertPropertyToStringAndWriteBack(CLIENT_REGISTRATION_ID, this::setClientRegistrationId);\n        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()){","sourceCodeStart":632,"sourceCodeEnd":668,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java#L632-L668","documentation":"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.","triggerScenarios":"-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.","commonSituations":"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.","solutions":["Remove clientRegistrationId if you do not use spring-http-interface with Boot 4","Or enable the full supported combination: -l spring-http-interface -c useSpringBoot4=true -c clientRegistrationId=my-client","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","For Boot 3 + OAuth2, keep clientRegistrationId out of generation and register the client in application.yml instead"],"exampleFix":"# before\nopenapi-generator-cli generate -i api.yaml -g spring -c clientRegistrationId=orders-api\n# after\nopenapi-generator-cli generate -i api.yaml -g spring -l spring-http-interface -c useSpringBoot4=true -c clientRegistrationId=orders-api","handlingStrategy":"validation","validationCode":"# bash: enforce the clientRegistrationId constraints up front\nif [[ -n \"${CLIENT_REGISTRATION_ID:-}\" ]]; then\n  [[ \"${LIBRARY:-}\" == spring-http-interface && \"${USE_SPRING_BOOT4:-false}\" == true ]] \\\n    || { echo 'clientRegistrationId requires -l spring-http-interface and useSpringBoot4=true'; exit 1; }\nfi","typeGuard":null,"tryCatchPattern":"try {\n    SpringCodegen codegen = new SpringCodegen();\n    codegen.setLibrary(\"spring-http-interface\");\n    codegen.additionalProperties().put(\"useSpringBoot4\", \"true\");\n    codegen.setClientRegistrationId(\"orders-api\");\n    new DefaultGenerator().opts(new ClientOptInput().opts(codegen)).generate();\n} catch (IllegalArgumentException e) {\n    // names the exact constraint: wrong library, or missing useSpringBoot4=true\n}","preventionTips":["Treat clientRegistrationId as a Boot 4 + spring-http-interface-only feature","For Boot 3 projects, keep OAuth2 registration in application.yml and do not pass the option","Centralize spring generator option presets per Spring Boot version so incompatible combos cannot be assembled"],"tags":["java","spring","codegen","oauth2","configuration","openapi-generator"],"backgroundTag":"incompatible-generator-options","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}