{"record":{"id":"25a9c5d13e80cae7","repo":"OpenAPITools/openapi-generator","slug":"mapnumberto-value-must-be-union-strictfloat-stric","errorCode":null,"errorMessage":"mapNumberTo value must be Union[StrictFloat, StrictInt], StrictStr or float","messagePattern":"mapNumberTo value must be Union\\[StrictFloat, StrictInt\\], StrictStr or float","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java","lineNumber":1606,"sourceCode":"                        exampleImports.add(cp.dataType);\n                    }\n                } else {\n                    LOGGER.error(\"Failed to look up {} from the imports (map of set) of models.\", cp.dataType);\n                }\n            }\n            return cp.dataType;\n        } else {\n            throw new RuntimeException(\"Error! Codegen Property not yet supported in getPydanticType: \" + cp);\n        }\n    }\n\n    public void setMapNumberTo(String mapNumberTo) {\n        if (\"Union[StrictFloat, StrictInt]\".equals(mapNumberTo)\n                || \"StrictFloat\".equals(mapNumberTo)\n                || \"float\".equals(mapNumberTo)) {\n            this.mapNumberTo = mapNumberTo;\n        } else {\n            throw new IllegalArgumentException(\"mapNumberTo value must be Union[StrictFloat, StrictInt], StrictStr or float\");\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        name = name.substring(1, name.length() - 1);\n\n        if (name.length() == 0) {\n            return \"EMPTY\";\n        }\n\n        if (\" \".equals(name)) {","sourceCodeStart":1588,"sourceCodeEnd":1624,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPythonPydanticV1Codegen.java#L1588-L1624","documentation":"AbstractPythonPydanticV1Codegen.setMapNumberTo accepts exactly three strings: 'Union[StrictFloat, StrictInt]', 'StrictFloat', 'float' (no Decimal — that value belongs to the non-v1 AbstractPythonCodegen set). Anything else throws this IllegalArgumentException. Beware the message text: it says 'StrictStr' but the code compares 'StrictFloat' — StrictStr is NOT actually accepted; the wording is a copy-paste bug in the message itself.","triggerScenarios":"-p mapNumberTo=StrictStr (suggested by the error text but rejected on retry), mapNumberTo=Decimal (valid for -g python, invalid for the pydantic-v1 generator), or any casing/whitespace deviation from the three exact strings, when generating with -g python-pydantic-v1.","commonSituations":"Cross-generator copy-paste of option values between python and python-pydantic-v1 configs; developers following the misleading error message and retrying with StrictStr.","solutions":["Use one of the exactly accepted values: float, StrictFloat, or Union[StrictFloat, StrictInt]","Do not use StrictStr here despite the message naming it — the comparison in the source is StrictFloat","If you need Decimal, generate with -g python instead, whose SUPPORTED_NUMBER_MAPPINGS includes it"],"exampleFix":"# before\njava -jar openapi-generator-cli.jar generate -g python-pydantic-v1 -i api.yaml -p mapNumberTo=StrictStr\n\n# after\njava -jar openapi-generator-cli.jar generate -g python-pydantic-v1 -i api.yaml -p mapNumberTo=StrictFloat","handlingStrategy":"validation","validationCode":"// Java: allowed values for the pydantic-v1 generator (no StrictStr, no Decimal)\nSet<String> allowed = Set.of(\"Union[StrictFloat, StrictInt]\", \"StrictFloat\", \"float\");\nString v = (String) config.additionalProperties().get(\"mapNumberTo\");\nif (v != null && !allowed.contains(v)) {\n    throw new IllegalArgumentException(\"mapNumberTo must be one of \" + allowed);\n}","typeGuard":null,"tryCatchPattern":"try { generator.generate(); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"mapNumberTo value must be\")) { /* pick float/StrictFloat/Union[...]; ignore the misleading StrictStr in the text */ } throw e; }","preventionTips":["Do not trust the error text here — the source accepts StrictFloat, not StrictStr","Keep per-generator option configs instead of sharing one across -g values","Prefer config files over CLI -p flags so values are reviewable"],"tags":["pydantic","python","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"}