{"record":{"id":"efd7a9f00a0a583b","repo":"OpenAPITools/openapi-generator","slug":"s-class-suffix-only-allows-alphanumeric-character-efd7a9","errorCode":null,"errorMessage":"%s class suffix only allows alphanumeric characters.","messagePattern":"(.+?) class suffix only allows alphanumeric characters\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java","lineNumber":522,"sourceCode":"     */\n    private void validateFileSuffixArgument(String argument, String value) {\n        if (!value.matches(FILE_NAME_SUFFIX_PATTERN)) {\n            throw new IllegalArgumentException(\n                    String.format(Locale.ROOT, \"%s file suffix only allows '.', '-' and alphanumeric characters.\", argument)\n            );\n        }\n    }\n\n    /**\n     * Validates that the given string value only contains alpha numeric characters.\n     * Throws an IllegalArgumentException, if the string contains any other characters.\n     *\n     * @param argument The name of the argument being validated. This is only used for displaying an error message.\n     * @param value    The value that is being validated.\n     */\n    private void validateClassSuffixArgument(String argument, String value) {\n        if (!value.matches(CLASS_NAME_SUFFIX_PATTERN)) {\n            throw new IllegalArgumentException(\n                    String.format(Locale.ROOT, \"%s class suffix only allows alphanumeric characters.\", argument)\n            );\n        }\n    }\n\n    /**\n     * Set the file naming type.\n     *\n     * @param fileNaming the file naming to use\n     */\n    private void setFileNaming(String fileNaming) {\n        if (\"camelCase\".equals(fileNaming) || \"kebab-case\".equals(fileNaming)) {\n            this.fileNaming = fileNaming;\n        } else {\n            throw new IllegalArgumentException(\"Invalid file naming '\" +\n                    fileNaming + \"'. Must be 'camelCase' or 'kebab-case'\");\n        }\n    }","sourceCodeStart":504,"sourceCodeEnd":540,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java#L504-L540","documentation":"The typescript-nestjs client generator validates the class-name suffix options 'serviceSuffix' and 'modelSuffix' against ^[a-zA-Z0-9]*$ (TypeScriptNestjsClientCodegen.java:47, validated at lines 187/195). Unlike file suffixes, dots and dashes are forbidden because the value is appended to TypeScript class/identifier names, where '.' and '-' would be syntax errors. %s in the message is 'Service' or 'Model'.","triggerScenarios":"Passing -DserviceSuffix=.Service or -DmodelSuffix=My-Model (dot or dash), or a suffix with underscores/spaces like '_service'. Thrown from processOpts during generation setup.","commonSituations":"Reusing the same suffix string for both class and file options (e.g. '.service' works for serviceFileSuffix but fails for serviceSuffix); copying naming conventions from Go/Java generators where dotted suffixes are common.","solutions":["Strip '.', '-' and '_' from the class suffix — use pure alphanumerics (e.g. 'Service', 'Model', 'GenModel').","Use separate values: dotted/kebab suffixes belong in serviceFileSuffix/modelFileSuffix only; keep serviceSuffix/modelSuffix alphanumeric.","Re-run generation; the message's %s ('Service' or 'Model') identifies the offending option."],"exampleFix":"# before\nopenapi-generator-cli generate -g typescript-nestjs \\\n  -DmodelSuffix=.Model\n\n# after\nopenapi-generator-cli generate -g typescript-nestjs \\\n  -DmodelSuffix=Model","handlingStrategy":"validation","validationCode":"if ! printf '%s' \"$SERVICE_SUFFIX$MODEL_SUFFIX\" | grep -Eq '^[a-zA-Z0-9]*$'; then\n  echo \"ERROR: class suffixes must be purely alphanumeric\" >&2\n  exit 1\nfi","typeGuard":"const isValidClassSuffix = (v: string | undefined): boolean =>\n  v === undefined || /^[a-zA-Z0-9]*$/.test(v);","tryCatchPattern":"catch (IllegalArgumentException e) {\n    // message labels the option ('Service'/'Model') — surface it and stop\n    throw new RuntimeException(\"Invalid typescript-nestjs class suffix: \" + e.getMessage(), e);\n}","preventionTips":["Never reuse a dotted/kebab value between *Suffix and *FileSuffix options.","Prefer camel-cased alphanumeric suffixes like 'Service' and 'Model' for classes."],"tags":["typescript","nestjs","codegen","config-validation","class-naming"],"backgroundTag":"invalid-option-value","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}