{"record":{"id":"77eaa8cb16de8bdf","repo":"OpenAPITools/openapi-generator","slug":"swagger1annotationlibrary-is-not-supported-with-sp-77eaa8","errorCode":null,"errorMessage":"swagger1AnnotationLibrary is not supported with Spring Boot > 3.x","messagePattern":"swagger1AnnotationLibrary is not supported with Spring Boot > 3\\.x","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java","lineNumber":663,"sourceCode":"        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){\n            this.applyJackson3Package();\n        } else {\n            this.applyJackson2Package();\n        }\n\n        convertPropertyToStringAndWriteBack(RESOURCE_FOLDER, this::setResourceFolder);\n        convertPropertyToBooleanAndWriteBack(USE_HTTP_SERVICE_PROXY_FACTORY_INTERFACES_CONFIGURATOR, this::setUseHttpServiceProxyFactoryInterfacesConfigurator);\n\n        convertPropertyToBooleanAndWriteBack(ADDITIONAL_NOT_NULL_ANNOTATIONS, this::setAdditionalNotNullAnnotations);\n","sourceCodeStart":645,"sourceCodeEnd":681,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java#L645-L681","documentation":"Thrown when annotationLibrary=swagger1 is combined with useSpringBoot3 or useSpringBoot4. Swagger 1.x annotations target javax.* packages and pre-Jakarta Spring, while Boot 3/4 generators switch templates to jakarta.* namespace. The generator rejects the combination up front instead of emitting sources that cannot compile.","triggerScenarios":"-g spring -DannotationLibrary=swagger1 with -DuseSpringBoot3=true or -DuseSpringBoot4=true.","commonSituations":"Upgrading a Boot 2 service to Boot 3/4 while keeping the old annotationLibrary setting; templates or docs that predate Springdoc; teams disabling springdoc for license reasons and falling back to swagger1 by habit.","solutions":["Use annotationLibrary=springdoc (recommended for Boot 3/4) or swagger2 instead.","Only keep swagger1 if you genuinely target Spring Boot 2.x, i.e. remove useSpringBoot3/useSpringBoot4."],"exampleFix":"# before\n-DannotationLibrary=swagger1 -DuseSpringBoot3=true\n\n# after\n-DannotationLibrary=springdoc -DuseSpringBoot3=true","handlingStrategy":"validation","validationCode":"# bash\nif { [ \"$USE_SPRING_BOOT3\" = \"true\" ] || [ \"$USE_SPRING_BOOT4\" = \"true\" ]; } \\\n   && [ \"$ANNOTATION_LIBRARY\" = \"swagger1\" ]; then\n  echo \"swagger1 annotations require Spring Boot 2.x\" >&2; exit 1\nfi","typeGuard":null,"tryCatchPattern":"// Java\ntry {\n    new DefaultGenerator().opts(input).generate();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"swagger1\")) {\n        // switch annotationLibrary to springdoc and re-run once with corrected config\n    }\n}","preventionTips":["Default new Boot 3/4 projects to annotationLibrary=springdoc.","Check the generator's supported-option matrix after any Spring Boot major upgrade.","Pin generator versions and review release notes for dropped annotation libraries."],"tags":["spring","swagger","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"}