{"record":{"id":"491ea4ba24519f82","repo":"OpenAPITools/openapi-generator","slug":"invalid-model-property-naming-name-must-be-o-491ea4","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/JavascriptApolloClientCodegen.java","lineNumber":472,"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        // 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        }\n\n        // if it's all upper case, do nothing\n        if (name.matches(\"^[A-Z_]*$\")) {\n            return name;\n        }","sourceCodeStart":454,"sourceCodeEnd":490,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java#L454-L490","documentation":"Defensive default arm inside getNameUsingModelPropertyNaming, which rewrites each model property name according to the configured convention for the javascript-apollo generator. The switch is over the MODEL_PROPERTY_NAMING_TYPE enum whose constants are exactly original, camelCase, PascalCase, snake_case — so the default arm is unreachable: an invalid string fails earlier, either in setModelPropertyNaming (which rejects unknown values) or at valueOf() itself. The message also prints the property name being converted rather than the invalid convention, which is misleading.","triggerScenarios":"Not reachable through supported inputs: `-p modelPropertyNaming=<bad>` is rejected by setModelPropertyNaming (JavascriptApolloClientCodegen.java:609) before this line runs. Only a subclass that assigns the modelPropertyNaming field directly to a non-enum string, or a future enum constant added without a matching case, could hit it.","commonSituations":"Rarely seen; developers who search this message almost always actually hit the identically-worded setter error caused by a misspelled modelPropertyNaming value.","solutions":["Treat this text as a modelPropertyNaming problem: check the option value first — the setter at JavascriptApolloClientCodegen.java:609 is the realistic source.","Use one of original, camelCase, PascalCase, snake_case with exact casing.","If you subclass this generator, set the convention via setModelPropertyNaming, never by direct field assignment."],"exampleFix":"# before\nopenapi-generator-cli generate -g javascript-apollo -i api.yaml -p modelPropertyNaming=snake\n# after\nopenapi-generator-cli generate -g javascript-apollo -i api.yaml -p modelPropertyNaming=snake_case","handlingStrategy":"validation","validationCode":"# validate at the option level — this line is a defensive arm, 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","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-apollo naming config rejected: \" + e.getMessage());\n}","preventionTips":["Validate modelPropertyNaming against the four-constant allowlist before generation.","In subclasses, use setModelPropertyNaming instead of assigning the field.","When you see this wording, first suspect the setter throw site, not this defensive branch."],"tags":["openapi-generator","javascript","apollo","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"}