{"record":{"id":"8c1a257409dae21c","repo":"OpenAPITools/openapi-generator","slug":"swagger1annotationlibrary-is-not-supported-with-sp","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/KotlinSpringServerCodegen.java","lineNumber":861,"sourceCode":"            this.setUseEnumValueInterface(convertPropertyToBoolean(CodegenConstants.USE_ENUM_VALUE_INTERFACE));\n        }\n        writePropertyBack(CodegenConstants.USE_ENUM_VALUE_INTERFACE, useEnumValueInterface);\n        if (isUseSpringBoot3() && isUseSpringBoot4()) {\n            throw new IllegalArgumentException(\"Choose between Spring Boot 3 and Spring Boot 4\");\n        }\n\n        if (isUseJackson3() && !isUseSpringBoot4()) {\n            throw new IllegalArgumentException(\"useJackson3 is only available with Spring Boot >= 4\");\n        }\n\n        if (additionalProperties.containsKey(CodegenConstants.OPENAPI_NULLABLE)) {\n            this.setOpenApiNullable(convertPropertyToBoolean(CodegenConstants.OPENAPI_NULLABLE));\n        }\n        writePropertyBack(CodegenConstants.OPENAPI_NULLABLE, openApiNullable);\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            additionalProperties.put(USE_JAKARTA_EE, useJakartaEe);\n            applyJakartaPackage();\n        }\n        writePropertyBack(USE_SPRING_BOOT3, isUseSpringBoot3());\n        writePropertyBack(USE_SPRING_BOOT4, isUseSpringBoot4());\n\n        modelTemplateFiles.put(\"model.mustache\", \".kt\");\n\n        if (!this.interfaceOnly && this.delegatePattern) {\n            apiTemplateFiles.put(\"apiInterface.mustache\", \".kt\");\n            apiTemplateFiles.put(\"apiController.mustache\", \"Controller.kt\");\n        } else if (interfaceOnly) {\n            apiTemplateFiles.put(\"apiInterface.mustache\", \".kt\");\n        } else {\n            apiTemplateFiles.put(\"api.mustache\", \"Controller.kt\");\n            apiTestTemplateFiles.put(\"api_test.mustache\", \".kt\");","sourceCodeStart":843,"sourceCodeEnd":879,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinSpringServerCodegen.java#L843-L879","documentation":"Swagger-Core 1.x annotations (swagger1) target the javax* namespace and predate Jakarta EE, so kotlin-spring refuses them when generating for Spring Boot 3 or 4. Inside the `isUseSpringBoot3() || isUseSpringBoot4()` block, processOpts() throws if the resolved annotation library is SWAGGER1 (KotlinSpringServerCodegen.java:861). This runs after the provider/library combination checks, so swagger1 itself is a supported library value for kotlin-spring — it is the Boot-version pairing that fails.","triggerScenarios":"Running with `--additional-properties useSpringBoot3=true,annotationLibrary=swagger1` (or useSpringBoot4=true with swagger1). The provider must be compatible with swagger1 too (e.g. documentationProvider=source or none), otherwise error 163 fires first.","commonSituations":"Long-lived kotlin-spring projects with swagger1 annotations being upgraded to Boot 3/4 while keeping the legacy annotation library; mixed option sets assembled from old wiki pages plus new Boot 3 flags.","solutions":["Migrate annotations: use `annotationLibrary=swagger2` (springdoc's pairing) with Boot 3/4.","Or drop the Boot 3/4 flags to generate Boot 2.x-era output with swagger1 (only as a temporary measure).","Search the generated sources for io.swagger.annotations imports after switching, and update hand-written code referencing them."],"exampleFix":"# before\nopenapi-generator-cli generate -g kotlin-spring -i api.yaml \\\n  --additional-properties useSpringBoot3=true,documentationProvider=source,annotationLibrary=swagger1\n# after\nopenapi-generator-cli generate -g kotlin-spring -i api.yaml \\\n  --additional-properties useSpringBoot3=true,documentationProvider=source,annotationLibrary=swagger2","handlingStrategy":"validation","validationCode":"boolean boot3plus = Boolean.parseBoolean(String.valueOf(opts.getOrDefault(\"useSpringBoot3\", \"false\")))\n        || Boolean.parseBoolean(String.valueOf(opts.getOrDefault(\"useSpringBoot4\", \"false\")));\nString al = String.valueOf(opts.getOrDefault(\"annotationLibrary\", \"SWAGGER2\")).toUpperCase(Locale.ROOT);\nif (boot3plus && \"SWAGGER1\".equals(al)) {\n    throw new IllegalArgumentException(\"swagger1 annotations require Spring Boot <= 2.x output\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (IllegalArgumentException e) {\n    throw new BuildException(\"Invalid kotlin-spring options: \" + e.getMessage(), e);\n}","preventionTips":["Plan a swagger1 → swagger2 annotation migration before upgrading generated code past Boot 3.","After regenerating, grep sources for io.swagger.annotations imports to catch leftovers.","Keep annotation library choice consistent with the Jakarta EE switch the Boot version implies."],"tags":["kotlin","spring","swagger","jakarta-ee","spring-boot-3","annotation-library","option-combination","openapi-generator","config-validation"],"backgroundTag":"incompatible-option-combination","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}