{"record":{"id":"5e7f6e1d54cc4fb3","repo":"OpenAPITools/openapi-generator","slug":"s-is-an-invalid-enum-property-naming-option-plea","errorCode":null,"errorMessage":"%s is an invalid enum property naming option. Please choose from:","messagePattern":"(.+?) is an invalid enum property naming option\\. Please choose from:","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java","lineNumber":1879,"sourceCode":"    }\n\n    public void setUseSourceGeneration(final Boolean useSourceGeneration) {\n        this.useSourceGeneration = useSourceGeneration;\n    }\n\n    public boolean getUseSourceGeneration() {\n        return this.useSourceGeneration;\n    }\n\n    public void setEnumPropertyNaming(final String enumPropertyNamingType) {\n        try {\n            this.enumPropertyNaming = CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.valueOf(enumPropertyNamingType);\n        } catch (IllegalArgumentException ex) {\n            StringBuilder sb = new StringBuilder(enumPropertyNamingType + \" is an invalid enum property naming option. Please choose from:\");\n            for (CodegenConstants.ENUM_PROPERTY_NAMING_TYPE t : CodegenConstants.ENUM_PROPERTY_NAMING_TYPE.values()) {\n                sb.append(\"\\n  \").append(t.name());\n            }\n            throw new RuntimeException(sb.toString());\n        }\n    }\n\n    @Override\n    public String toEnumValue(String value, String datatype) {\n        // C# only supports enums as literals for int, int?, long, long?, byte, and byte?. All else must be treated as strings.\n        // Per: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/enum\n        // The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong.\n        // but we're not supporting unsigned integral types or shorts.\n        if (datatype.startsWith(\"int\") || datatype.startsWith(\"uint\") ||\n                datatype.startsWith(\"long\") || datatype.startsWith(\"ulong\") ||\n                datatype.startsWith(\"byte\")) {\n            return value;\n        }\n\n        final String partiallyEscaped = value\n                .replace(\"\\n\", \"\\\\n\")\n                .replace(\"\\t\", \"\\\\t\")","sourceCodeStart":1861,"sourceCodeEnd":1897,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java#L1861-L1897","documentation":"AbstractCSharpCodegen.setEnumPropertyNaming parses the enumPropertyNaming option into CodegenConstants.ENUM_PROPERTY_NAMING_TYPE. A string that is not one of the enum constants throws this RuntimeException, with the message appending the full list of valid values.","triggerScenarios":"Passing -p enumPropertyNaming=camelcase (wrong case) or a nonexistent value like upper_snake with a C# generator (csharp, csharp-netcore). The value is matched case-sensitively against the constants camelCase, PascalCase, snake_case, original, UPPERCASE.","commonSituations":"Typos and wrong casing in generator config; copying an enumPropertyNaming value that only exists in a different generator family (e.g. a Kotlin-only or Java-only value); options carried over from an older release whose value set differed.","solutions":["Use exactly one of the values printed in the error message (camelCase, PascalCase, snake_case, original, UPPERCASE) — matching case.","Check for spelling/casing slips such as camelcase, pascalCase, or snake-case.","When moving configs between generator versions or languages, re-check that generator's supported naming options."],"exampleFix":"# before:\nopenapi-generator-cli generate -g csharp-netcore -i api.yaml -p enumPropertyNaming=camelcase\n# after:\nopenapi-generator-cli generate -g csharp-netcore -i api.yaml -p enumPropertyNaming=camelCase","handlingStrategy":"type-guard","validationCode":"// Validate before passing the option\nif (!isCSharpEnumNaming(opts.enumPropertyNaming)) {\n    throw new Error('enumPropertyNaming must be one of camelCase, PascalCase, snake_case, original, UPPERCASE');\n}","typeGuard":"const CSHARP_ENUM_PROPERTY_NAMING = ['camelCase', 'PascalCase', 'snake_case', 'original', 'UPPERCASE'] as const;\nexport type CSharpEnumPropertyNaming = typeof CSHARP_ENUM_PROPERTY_NAMING[number];\nexport function isCSharpEnumNaming(v: string): v is CSharpEnumPropertyNaming {\n    return (CSHARP_ENUM_PROPERTY_NAMING as readonly string[]).includes(v);\n}","tryCatchPattern":null,"preventionTips":["Treat enumPropertyNaming as a case-sensitive enum, not free text.","Keep option values for C# generation in a typed config object guarded by isCSharpEnumNaming before building the CLI command.","Note the valid set differs per language family — do not share one naming option across generators."],"tags":["openapi","csharp","enum","naming","configuration"],"backgroundTag":"invalid-enum-property-naming","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}