{"record":{"id":"9387cb76510766d7","repo":"OpenAPITools/openapi-generator","slug":"value-value-for-the-generateswaggerannotations","errorCode":null,"errorMessage":"Value \"{value}\" for the generateSwaggerAnnotations parameter is unsupported or misspelled","messagePattern":"Value \"(.+?)\" for the generateSwaggerAnnotations parameter is unsupported or misspelled","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaMicronautAbstractCodegen.java","lineNumber":311,"sourceCode":"        } else if (testTool.equals(OPT_TEST_SPOCK)) {\n            additionalProperties.put(\"isTestSpock\", true);\n        }\n\n        if (additionalProperties.containsKey(OPT_GENERATE_SWAGGER_ANNOTATIONS)) {\n            String value = String.valueOf(additionalProperties.get(OPT_GENERATE_SWAGGER_ANNOTATIONS));\n            switch (value) {\n                case OPT_GENERATE_SWAGGER_ANNOTATIONS_SWAGGER_1:\n                    this.generateSwaggerAnnotations = OPT_GENERATE_SWAGGER_ANNOTATIONS_SWAGGER_1;\n                    break;\n                case OPT_GENERATE_SWAGGER_ANNOTATIONS_SWAGGER_2:\n                case OPT_GENERATE_SWAGGER_ANNOTATIONS_TRUE:\n                    this.generateSwaggerAnnotations = OPT_GENERATE_SWAGGER_ANNOTATIONS_SWAGGER_2;\n                    break;\n                case OPT_GENERATE_SWAGGER_ANNOTATIONS_FALSE:\n                    this.generateSwaggerAnnotations = OPT_GENERATE_SWAGGER_ANNOTATIONS_FALSE;\n                    break;\n                default:\n                    throw new RuntimeException(\"Value \\\"\" + value + \"\\\" for the \" + OPT_GENERATE_SWAGGER_ANNOTATIONS + \" parameter is unsupported or misspelled\");\n            }\n        }\n        if (OPT_GENERATE_SWAGGER_ANNOTATIONS_SWAGGER_1.equals(this.generateSwaggerAnnotations)) {\n            additionalProperties.put(\"generateSwagger1Annotations\", true);\n        } else if (OPT_GENERATE_SWAGGER_ANNOTATIONS_SWAGGER_2.equals(this.generateSwaggerAnnotations)) {\n            additionalProperties.put(\"generateSwagger2Annotations\", true);\n        }\n\n        if (additionalProperties.containsKey(CodegenConstants.SERIALIZATION_LIBRARY)) {\n            setSerializationLibrary((String) additionalProperties.get(CodegenConstants.SERIALIZATION_LIBRARY));\n        }\n        additionalProperties.put(this.serializationLibrary, true);\n        this.jackson = JACKSON.equals(this.serializationLibrary);\n\n        // Add all the supporting files\n        String resourceFolder = projectFolder + \"/resources\";\n        supportingFiles.add(new SupportingFile(\"common/configuration/application.yml.mustache\", resourceFolder, \"application.yml\").doNotOverwrite());\n        supportingFiles.add(new SupportingFile(\"common/configuration/logback.xml.mustache\", resourceFolder, \"logback.xml\").doNotOverwrite());","sourceCodeStart":293,"sourceCodeEnd":329,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaMicronautAbstractCodegen.java#L293-L329","documentation":"Validates the 'generateSwaggerAnnotations' additional property (OPT_GENERATE_SWAGGER_ANNOTATIONS) of the Micronaut Java generators. Accepted values are exactly: 'swagger1' (io.swagger:swagger-annotations), 'swagger2' (io.swagger.core.v3:swagger-annotations), 'true' (alias for swagger2), and 'false' (no annotations). The raw value is stringified with String.valueOf then matched case-sensitively; anything else throws a RuntimeException from processOpts.","triggerScenarios":"-p generateSwaggerAnnotations=TRUE (uppercase), =1, =2, =yes, =none, =v2, =swagger (bare). Note a real boolean true/false passed programmatically works because String.valueOf(true) yields \"true\", but the uppercase string \"TRUE\" fails.","commonSituations":"Assuming the annotation version is picked with 1/2 or v1/v2; YAML config loaders that preserve 'TRUE' casing from hand-edited files; blog posts using long-form values like 'swagger-annotations'.","solutions":["Use exactly `swagger1`, `swagger2`, `true`, or `false` (all lowercase).","Remember `true` is equivalent to `swagger2`; use `false` to disable annotation generation.","If unsure, omit the option — the generator picks a default (false or swagger2 depending on client/server variant) and never throws when absent."],"exampleFix":"# before\nopenapi-generator-cli generate -g java-micronaut -i api.yaml -p generateSwaggerAnnotations=TRUE\n# after\nopenapi-generator-cli generate -g java-micronaut -i api.yaml -p generateSwaggerAnnotations=true","handlingStrategy":"validation","validationCode":"# shell: validate the swagger annotations mode first\nv=\"${SWAGGER_ANNOTATIONS:-}\"\n[ -z \"$v\" ] || case \"$v\" in\n  swagger1|swagger2|true|false) ;;\n  *) echo \"generateSwaggerAnnotations must be swagger1|swagger2|true|false, got: $v\" >&2; exit 2 ;;\nesac","typeGuard":"private static final java.util.Set<String> SWAGGER_ANNOTATION_MODES =\n        java.util.Set.of(\"swagger1\", \"swagger2\", \"true\", \"false\");\n\nboolean isValidSwaggerAnnotationsMode(String v) {\n    return v == null || SWAGGER_ANNOTATION_MODES.contains(v);\n}","tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (RuntimeException e) {\n    failBuild(\"generateSwaggerAnnotations value rejected: \" + e.getMessage());\n}","preventionTips":["Normalize the value to lowercase before passing it (tr \"[:upper:]\" \"[:lower:]\").","Prefer the explicit swagger1/swagger2 forms over true/false to make intent obvious.","Add a CI lint that greps config files for unlisted generateSwaggerAnnotations values."],"tags":["openapi-generator","java","micronaut","configuration","swagger-annotations"],"backgroundTag":"invalid-generator-option-value","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}