OpenAPITools/openapi-generator · error · IllegalArgumentException

Invalid model property naming '{naming}'. Must be 'original'

Error message

Invalid model property naming '{naming}'. Must be 'original', 'camelCase', 'PascalCase' or 'snake_case'

What it means

Setter validating the 'modelPropertyNaming' additional property of the javascript-apollo generator. Only original, camelCase, PascalCase and snake_case are accepted, matched case-sensitively via chained equals; anything else throws IllegalArgumentException during option processing, aborting generation before any output file is written. The default convention is camelCase.

Source

Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java:609

        } else if (ModelUtils.isIntegerSchema(p)) {
            if (p.getDefault() != null) {
                return p.getDefault().toString();
            }
        } else if (ModelUtils.isStringSchema(p)) {
            if (p.getDefault() != null) {
                return "'" + p.getDefault() + "'";
            }
        }

        return null;
    }

    public void setModelPropertyNaming(String naming) {
        if ("original".equals(naming) || "camelCase".equals(naming) ||
                "PascalCase".equals(naming) || "snake_case".equals(naming)) {
            this.modelPropertyNaming = naming;
        } else {
            throw new IllegalArgumentException("Invalid model property naming '" +
                    naming + "'. Must be 'original', 'camelCase', " +
                    "'PascalCase' or 'snake_case'");
        }
    }

    @Override
    public String toDefaultValueWithParam(String name, Schema p) {
        String type = normalizeType(getTypeDeclaration(p));
        if (!StringUtils.isEmpty(p.get$ref())) {
            return " = " + type + ".constructFromObject(data['" + name + "']);";
        } else {
            return " = ApiClient.convertToType(data['" + name + "'], " + type + ");";
        }
    }

    @Override
    public void setParameterExampleValue(CodegenParameter p) {
        String example;

View on GitHub (pinned to fcec517be3)

Solutions

  1. Use exactly `original`, `camelCase`, `PascalCase`, or `snake_case`.
  2. Omit the option to keep the camelCase default.
  3. Cross-check against `openapi-generator-cli config-help -g javascript-apollo` before running.

Example fix

# before
openapi-generator-cli generate -g javascript-apollo -i api.yaml -p modelPropertyNaming=camelcase
# after
openapi-generator-cli generate -g javascript-apollo -i api.yaml -p modelPropertyNaming=camelCase
Defensive patterns

Strategy: validation

Validate before calling

# shell: exact-case allowlist for javascript-apollo
mpn="${MODEL_PROPERTY_NAMING:-camelCase}"
case "$mpn" in
  original|camelCase|PascalCase|snake_case) ;;
  *) echo "modelPropertyNaming must be original|camelCase|PascalCase|snake_case (case-sensitive), got: $mpn" >&2; exit 2 ;;
esac

Type guard

type ModelPropertyNaming = 'original' | 'camelCase' | 'PascalCase' | 'snake_case';
const NAMING: Set<string> = new Set(['original', 'camelCase', 'PascalCase', 'snake_case']);
function isModelPropertyNaming(v: string): v is ModelPropertyNaming {
  return NAMING.has(v);
}

Try / catch

try {
    new DefaultGenerator().opts(clientOptInput).generate();
} catch (IllegalArgumentException e) {
    throw new IllegalStateException("Invalid modelPropertyNaming for javascript-apollo: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: `-g javascript-apollo -p modelPropertyNaming=snake` (dropping '_case'); `camelcase` or `CamelCase` (wrong casing — the accepted forms are 'camelCase' and 'PascalCase'); `kebab-case`; `hyphen`; any value typed programmatically via setModelPropertyNaming.

Common situations: Porting config from another generator; case typos in hand-written YAML; assuming the convention name can be abbreviated.

Related errors


AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22). Data as JSON: /api/errors/4726e3b9e6be7fb0. Report an issue: GitHub.