{"record":{"id":"137f272db7449db0","repo":"OpenAPITools/openapi-generator","slug":"s-class-prefix-only-allows-alphanumeric-character","errorCode":null,"errorMessage":"%s class prefix only allows alphanumeric characters.","messagePattern":"(.+?) class prefix only allows alphanumeric characters\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java","lineNumber":679,"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 validateClassPrefixArgument(String argument, String value) {\n        if (!value.matches(CLASS_NAME_PREFIX_PATTERN)) {\n            throw new IllegalArgumentException(\n                    String.format(Locale.ROOT, \"%s class prefix only allows 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        }","sourceCodeStart":661,"sourceCodeEnd":697,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAngularClientCodegen.java#L661-L697","documentation":"Class-prefix options (apiModulePrefix, configurationPrefix) are validated for alphanumeric-only content, because the prefix is concatenated into generated class names such as ApiModule and Configuration. Non-alphanumeric characters would produce invalid TypeScript identifiers.","triggerScenarios":"-DapiModulePrefix=My-Api or -DconfigurationPrefix=$conf — any prefix matching outside [A-Za-z0-9]+.","commonSituations":"Using namespace-style prefixes with dots or dashes; pasting vendor prefixes that include symbols; monorepo naming conventions that assume hyphenated module names.","solutions":["Use a purely alphanumeric prefix, e.g. -DapiModulePrefix=Acme.","Remove the prefix option to accept the default class names."],"exampleFix":"# before\n-DapiModulePrefix=acme-api\n\n# after\n-DapiModulePrefix=AcmeApi","handlingStrategy":"validation","validationCode":"// node: class prefixes must be alphanumeric\nconst ALNUM = /^[A-Za-z0-9]+$/;\nfor (const [k, v] of Object.entries({ apiModulePrefix: opts.apiModulePrefix, configurationPrefix: opts.configurationPrefix }))\n  if (v && !ALNUM.test(v)) throw new Error(`${k} must be alphanumeric, got: ${v}`);","typeGuard":"const isValidClassPrefix = (v: string): boolean => /^[A-Za-z0-9]+$/.test(v);","tryCatchPattern":"// Java\ntry { new DefaultGenerator().opts(input).generate(); }\ncatch (IllegalArgumentException e) {\n    // prefix rejected: sanitize to alphanumeric (strip -._) and rerun\n}","preventionTips":["Treat prefix options as identifier parts, not free text.","Add a config lint step for naming options before generation.","Prefer camel- or Pascal-case single-word prefixes."],"tags":["typescript","angular","configuration","naming"],"backgroundTag":"invalid-option-value","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}