OpenAPITools/openapi-generator · error · IllegalArgumentException

Invalid model property naming '%s'. Must be 'original', 'cam

Error message

Invalid model property naming '%s'. Must be 'original', 'camelCase', 'PascalCase' or 'snake_case'

What it means

AbstractFSharpCodegen.setModelPropertyNaming (the message's real throw site, lines 641-649) throws IllegalArgumentException when the modelPropertyNaming option is not exactly 'original', 'camelCase', 'PascalCase' or 'snake_case'. The value arrives via additionalProperties/-p modelPropertyNaming=... and is compared by exact string match before being stored.

Source

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

        return outputFolder + File.separator + sourceFolder + File.separator + apiPackage();
    }

    @Override
    public String modelFileFolder() {
        return outputFolder + File.separator + sourceFolder + File.separator + modelPackage();
    }

    @Override
    public String toModelFilename(String name) {
        // should be the same as the model name
        return toModelName(name);
    }

    @Override
    public String toOperationId(String operationId) {
        // throw exception if method name is empty (should not occur as an auto-generated method name will be used)
        if (StringUtils.isEmpty(operationId)) {
            throw new RuntimeException("Empty method name (operationId) not allowed");
        }

        // method name cannot use reserved keyword, e.g. return
        if (isReservedWord(operationId)) {
            LOGGER.warn("{} (reserved word) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId)));
            operationId = "call_" + operationId;
        }

        // operationId starts with a number
        if (operationId.matches("^\\d.*")) {
            LOGGER.warn("{} (starting with a number) cannot be used as method name. Renamed to {}", operationId, camelize(sanitizeName("call_" + operationId)));
            operationId = "call_" + operationId;
        }

        return camelize(sanitizeName(operationId));
    }

    public void setModelPropertyNaming(String naming) {

View on GitHub (pinned to fcec517be3)

Solutions

  1. Use one of exactly: original, camelCase, PascalCase, snake_case (case-sensitive).
  2. Fix hyphen/casing slips such as snake-case or camelcase.
  3. If you need uppercase naming, check the F# generator's supported options — UPPERCASE is not among them; post-process instead.

Example fix

# before:
openapi-generator-cli generate -g fsharp-giraffe-server -i api.yaml -p modelPropertyNaming=snake-case
# after:
openapi-generator-cli generate -g fsharp-giraffe-server -i api.yaml -p modelPropertyNaming=snake_case
Defensive patterns

Strategy: type-guard

Validate before calling

// Validate before passing the option
if (!isModelPropertyNaming(opts.modelPropertyNaming)) {
    throw new Error('modelPropertyNaming must be original, camelCase, PascalCase or snake_case');
}

Type guard

const FSHARP_MODEL_PROPERTY_NAMING = ['original', 'camelCase', 'PascalCase', 'snake_case'] as const;
export type FSharpModelPropertyNaming = typeof FSHARP_MODEL_PROPERTY_NAMING[number];
export function isModelPropertyNaming(v: string): v is FSharpModelPropertyNaming {
    return (FSHARP_MODEL_PROPERTY_NAMING as readonly string[]).includes(v);
}

Prevention

When it happens

Trigger: Running an F# generator (e.g. -g fsharp-giraffe-server) with -p modelPropertyNaming=Pascalcase, snake-case, or any other casing/spelling slip: none of the four equals() checks match and the exception aborts option processing.

Common situations: Wrong casing ('camelcase', 'pascalCase'); hyphen instead of underscore ('snake-case'); copying a value valid in another generator (e.g. 'UPPERCASE', which F# does not accept) from a shared config or CI template.

Related errors


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