{"record":{"id":"1d00687c49cba42b","repo":"OpenAPITools/openapi-generator","slug":"mapnumberto-supports-s","errorCode":null,"errorMessage":"mapNumberTo supports %s","messagePattern":"mapNumberTo supports (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java","lineNumber":1241,"sourceCode":"                                       PythonImports moduleImports,\n                                       String classname) {\n        PydanticType pt = new PydanticType(\n                modelImports,\n                exampleImports,\n                postponedModelImports,\n                postponedExampleImports,\n                moduleImports,\n                classname\n        );\n\n        return pt.getType(cp);\n    }\n\n    public void setMapNumberTo(String mapNumberTo) {\n        if (SUPPORTED_NUMBER_MAPPINGS.contains(mapNumberTo)) {\n            this.mapNumberTo = mapNumberTo;\n        } else {\n            throw new IllegalArgumentException(String.format(Locale.ROOT, \"mapNumberTo supports %s\", SUPPORTED_NUMBER_MAPPINGS));\n        }\n    }\n\n    public String toEnumVariableName(String name, String datatype) {\n        name = name.replace(\".\", \"_DOT_\");\n\n        if (\"int\".equals(datatype)) {\n            return \"NUMBER_\" + name.replace(\"-\", \"MINUS_\");\n        }\n\n        // remove quote e.g. 'abc' => abc\n        if (name.startsWith(\"'\") && name.endsWith(\"'\")) {\n            name = name.substring(1, name.length() - 1);\n        }\n\n        if (name.length() == 0) {\n            return \"EMPTY\";\n        }","sourceCodeStart":1223,"sourceCodeEnd":1259,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonCodegen.java#L1223-L1259","documentation":"Thrown by setMapNumberTo in AbstractPythonCodegen, the base for the modern Python generators (python, python-fastapi, etc.). The mapNumberTo option selects which Python type OpenAPI 'number' properties map to, and only the strings in SUPPORTED_NUMBER_MAPPINGS are accepted: 'Union[StrictFloat, StrictInt]', 'StrictFloat', 'float', 'Decimal'. Any other string fails with this IllegalArgumentException; the message interpolates the exact allowed set.","triggerScenarios":"Running a Python-family generator with -p mapNumberTo=<value> (or additionalProperties in the Maven/Gradle plugin) where <value> is not byte-for-byte one of the four allowed strings: mapNumberTo=StrictStr, mapNumberTo=decimal (lowercase), mapNumberTo=Decimal on an old release before Decimal was added, or 'Union[StrictFloat, StrictInt]' with stray whitespace or smart quotes.","commonSituations":"Copying mapNumberTo=StrictStr from pydantic-v1 generator examples (valid there, rejected by this codegen); case/bracket typos in the Union value; upgrading or downgrading generator versions where the accepted set differed.","solutions":["Re-run with an exact allowed value: -p mapNumberTo=float (the default), StrictFloat, Decimal, or Union[StrictFloat, StrictInt]","Remove the option entirely and accept the generator default while you verify the spelling","If you need pydantic strict types such as StrictStr, switch to the pydantic-v1 based generator (e.g. -g python-pydantic-v1) where that value is accepted","Check for case sensitivity, exact brackets and commas — the check is an exact Set.contains string comparison"],"exampleFix":"# before\njava -jar openapi-generator-cli.jar generate -g python -i api.yaml -p mapNumberTo=StrictStr\n\n# after\njava -jar openapi-generator-cli.jar generate -g python -i api.yaml -p mapNumberTo=Union[StrictFloat, StrictInt]","handlingStrategy":"validation","validationCode":"// Java (before calling the generator)\nSet<String> allowed = Set.of(\"Union[StrictFloat, StrictInt]\", \"StrictFloat\", \"float\", \"Decimal\");\nString v = (String) config.additionalProperties().get(\"mapNumberTo\");\nif (v != null && !allowed.contains(v)) {\n    throw new IllegalArgumentException(\"mapNumberTo must be one of \" + allowed + \", got: \" + v);\n}","typeGuard":null,"tryCatchPattern":"try { generator.generate(); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"mapNumberTo supports\")) { /* config error: fix the option value, do not retry */ } throw e; }","preventionTips":["Keep generator options in a checked-in config (-c config.json) instead of ad-hoc CLI flags","Validate -p key=value pairs against the generator's documented option list in a pre-build step","Remember the accepted set differs between -g python and -g python-pydantic-v1"],"tags":["python","openapi-generator","configuration","cli-option"],"backgroundTag":"invalid-generator-option","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}