{"record":{"id":"6a2bf40a18acd523","repo":"OpenAPITools/openapi-generator","slug":"s-file-suffix-only-allows-and-alphanumer-6a2bf4","errorCode":null,"errorMessage":"%s file suffix only allows '.', '-' and alphanumeric characters.","messagePattern":"(.+?) file suffix only allows '\\.', '-' and alphanumeric characters\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsServerCodegen.java","lineNumber":568,"sourceCode":"            result = result.substring(prefix.length());\n        }\n        if (suffix.length() > 0 && result.endsWith(suffix)) {\n            result = result.substring(0, result.length() - suffix.length());\n        }\n\n        return result;\n    }\n\n    /**\n     * Validates that the given string value only contains '-', '.' and 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 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        }","sourceCodeStart":550,"sourceCodeEnd":586,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsServerCodegen.java#L550-L586","documentation":"The typescript-nestjs server generator validates the file-suffix options 'apiFileSuffix' and 'modelFileSuffix' against ^[a-zA-Z0-9.-]*$ (TypeScriptNestjsServerCodegen.java:49, validated at lines 227/235). Unlike the client variant, this check is guarded by 'value != null', so an unset suffix passes; only a non-null value containing characters outside '.', '-' and alphanumerics throws. %s in the message is 'Service' or 'Model'.","triggerScenarios":"Generating a NestJS server with -DapiFileSuffix=_api or -DmodelFileSuffix=.gen.model.ts? — any non-null suffix matching [^a-zA-Z0-9.-] (underscore, space, slash) throws during processOpts. Note the option is named apiFileSuffix but the message label is 'Service'.","commonSituations":"Server scaffolds that follow snake_case file conventions; sharing one -D options string between client and server generation where the client uses serviceFileSuffix and the server apiFileSuffix; trailing whitespace in CI variables.","solutions":["Restrict the suffix to letters, digits, '.' and '-' (e.g. '.api' instead of '_api').","Check apiFileSuffix and modelFileSuffix — the %s label ('Service'/'Model') tells you which failed.","Alternatively omit the suffix option entirely; null values are accepted by the server generator."],"exampleFix":"# before\nopenapi-generator-cli generate -g typescript-nestjs-server \\\n  -DapiFileSuffix=_api\n\n# after\nopenapi-generator-cli generate -g typescript-nestjs-server \\\n  -DapiFileSuffix=.api","handlingStrategy":"validation","validationCode":"if ! printf '%s' \"$API_FILE_SUFFIX$MODEL_FILE_SUFFIX\" | grep -Eq '^[a-zA-Z0-9.-]*$'; then\n  echo \"ERROR: file suffixes may only contain '.', '-' and alphanumerics\" >&2\n  exit 1\nfi","typeGuard":"const isValidFileSuffix = (v: string | null | undefined): boolean =>\n  v == null || /^[a-zA-Z0-9.-]*$/.test(v); // null is accepted by the server generator","tryCatchPattern":"catch (IllegalArgumentException e) {\n    throw new RuntimeException(\"Invalid typescript-nestjs-server suffix option: \" + e.getMessage(), e);\n}","preventionTips":["Remember the server uses apiFileSuffix (message still says 'Service') — check that key first.","Centralize suffix constants in one CI variable file so client and server builds stay consistent."],"tags":["typescript","nestjs","server","codegen","config-validation","file-naming"],"backgroundTag":"invalid-option-value","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}