{"record":{"id":"0d20ca5fcf5ad877","repo":"OpenAPITools/openapi-generator","slug":"s-class-suffix-only-allows-alphanumeric-character-0d20ca","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/TypeScriptNestjsServerCodegen.java","lineNumber":583,"sourceCode":"     */\n    private void validateFileSuffixArgument(String argument, String value) {\n        if (value != null && !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 != null && !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":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsServerCodegen.java#L565-L601","documentation":"The typescript-nestjs server generator validates the class-suffix options 'apiSuffix' and 'modelSuffix' against ^[a-zA-Z0-9]*$ (TypeScriptNestjsServerCodegen.java:48, validated at lines 223/231). The value is appended to generated TypeScript class names, so dots, dashes and underscores are rejected; a null value is allowed (value != null guard) and simply skips validation. %s is 'Service' or 'Model'.","triggerScenarios":"Passing -DapiSuffix=.Controller or -DmodelSuffix=My-Model — any non-null suffix with a non-alphanumeric character throws during processOpts. The option key is apiSuffix but the error label reads 'Service'.","commonSituations":"Wanting generated controller classes named like 'UserController' by passing '.Controller'; copying the same suffix into both apiSuffix and apiFileSuffix; migrating from the client generator where option names differ.","solutions":["Use a purely alphanumeric class suffix ('Controller', 'Service', 'Api').","Keep dotted/dashed naming for apiFileSuffix/modelFileSuffix only.","Omit the option if the default suffix is acceptable — null passes validation."],"exampleFix":"# before\nopenapi-generator-cli generate -g typescript-nestjs-server \\\n  -DapiSuffix=.Controller\n\n# after\nopenapi-generator-cli generate -g typescript-nestjs-server \\\n  -DapiSuffix=Controller","handlingStrategy":"validation","validationCode":"if ! printf '%s' \"$API_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 | null | undefined): boolean =>\n  v == null || /^[a-zA-Z0-9]*$/.test(v);","tryCatchPattern":null,"preventionTips":["Class suffixes: alphanumeric only — no '.', '-', '_'.","Null/unset suffixes are legal on the server generator; when in doubt, omit the option."],"tags":["typescript","nestjs","server","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"}