{"record":{"id":"26acfe6792ad2c94","repo":"OpenAPITools/openapi-generator","slug":"invalid-model-property-naming-name-must-be-o-26acfe","errorCode":null,"errorMessage":"Invalid model property naming '{name}'. Must be 'original', 'camelCase', 'PascalCase' or 'snake_case'","messagePattern":"Invalid model property naming '(.+?)'\\. Must be 'original', 'camelCase', 'PascalCase' or 'snake_case'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java","lineNumber":487,"sourceCode":"    }\n\n    @Override\n    public String toModelTestFilename(String name) {\n        return toModelName(name) + \".spec\";\n    }\n\n    private String getNameUsingModelPropertyNaming(String name) {\n        switch (CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.valueOf(getModelPropertyNaming())) {\n            case original:\n                return name;\n            case camelCase:\n                return camelize(name, LOWERCASE_FIRST_LETTER);\n            case PascalCase:\n                return camelize(name);\n            case snake_case:\n                return underscore(name);\n            default:\n                throw new IllegalArgumentException(\"Invalid model property naming '\" +\n                        name + \"'. Must be 'original', 'camelCase', \" +\n                        \"'PascalCase' or 'snake_case'\");\n        }\n    }\n\n    @Override\n    public String toVarName(String name) {\n        // obtain the name from nameMapping directly if provided\n        if (nameMapping.containsKey(name)) {\n            return nameMapping.get(name);\n        }\n\n        // sanitize name\n        name = sanitizeName(name);  // FIXME parameter should not be assigned. Also declare it as \"final\"\n\n        if (\"_\".equals(name)) {\n            name = \"_u\";\n        }","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java#L469-L505","documentation":"Defensive default arm inside getNameUsingModelPropertyNaming of the plain javascript generator: it rewrites property names according to the configured convention. The switch covers exactly the MODEL_PROPERTY_NAMING_TYPE constants (original, camelCase, PascalCase, snake_case), so the default arm is effectively unreachable — invalid values are rejected earlier by setModelPropertyNaming (JavascriptClientCodegen.java:639) or by valueOf(). The message prints the property name being converted instead of the bad convention, which is misleading.","triggerScenarios":"Not reachable via supported inputs: `-p modelPropertyNaming=<bad>` fails first in the setter. Only subclasses assigning the modelPropertyNaming field directly, or a future enum constant without a matching case, could land here.","commonSituations":"Almost never fires; developers hitting this text usually did so via the identically-worded setter error caused by a misspelled modelPropertyNaming value.","solutions":["Check your `modelPropertyNaming` value — the setter at JavascriptClientCodegen.java:639 is the realistic source of this message.","Use exactly original, camelCase, PascalCase, or snake_case.","Set the convention only through the setter / additionalProperties, never by field access in subclasses."],"exampleFix":"# before\nopenapi-generator-cli generate -g javascript -i api.yaml -p modelPropertyNaming=Pascal_Case\n# after\nopenapi-generator-cli generate -g javascript -i api.yaml -p modelPropertyNaming=PascalCase","handlingStrategy":"validation","validationCode":"# validate the option — the default branch here is defensive; the setter is the real gate\nmpn=\"${MODEL_PROPERTY_NAMING:-camelCase}\"\ncase \"$mpn\" in\n  original|camelCase|PascalCase|snake_case) ;;\n  *) echo \"modelPropertyNaming must be original|camelCase|PascalCase|snake_case, got: $mpn\" >&2; exit 2 ;;\nesac\nopenapi-generator-cli generate -g javascript -i api.yaml -p modelPropertyNaming=\"$mpn\"","typeGuard":"private static final java.util.Set<String> NAMING_CONVENTIONS =\n        java.util.Set.of(\"original\", \"camelCase\", \"PascalCase\", \"snake_case\");\n\nboolean isValidNamingConvention(String v) {\n    return v != null && NAMING_CONVENTIONS.contains(v);\n}","tryCatchPattern":"try {\n    new DefaultGenerator().opts(clientOptInput).generate();\n} catch (RuntimeException e) {\n    failBuild(\"javascript generator naming config rejected: \" + e.getMessage());\n}","preventionTips":["Check the modelPropertyNaming value first when this wording appears; the setter throw site is the realistic source.","Use the four-constant allowlist in your build script.","Never assign the convention by field access in subclasses."],"tags":["openapi-generator","javascript","configuration","naming"],"backgroundTag":"invalid-model-property-naming","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}