{"record":{"id":"9f51d46ab9587010","repo":"OpenAPITools/openapi-generator","slug":"unexpected-serializationlibrary-value-serializat","errorCode":null,"errorMessage":"Unexpected serializationLibrary value: {serializationLibrary}","messagePattern":"Unexpected serializationLibrary value: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java","lineNumber":1360,"sourceCode":"        writePropertyBack(JACKSON_PACKAGE, JACKSON2_PACKAGE);\n    }\n\n    protected void applyJackson3Package() {\n        writePropertyBack(JACKSON_PACKAGE, JACKSON3_PACKAGE);\n    }\n\n    public void setSerializationLibrary(String serializationLibrary) {\n        if (SERIALIZATION_LIBRARY_JACKSON.equalsIgnoreCase(serializationLibrary)) {\n            this.serializationLibrary = SERIALIZATION_LIBRARY_JACKSON;\n            this.jackson = true;\n        } else if (SERIALIZATION_LIBRARY_GSON.equalsIgnoreCase(serializationLibrary)) {\n            this.serializationLibrary = SERIALIZATION_LIBRARY_GSON;\n            this.jackson = false;\n        } else if (SERIALIZATION_LIBRARY_JSONB.equalsIgnoreCase(serializationLibrary)) {\n            this.serializationLibrary = SERIALIZATION_LIBRARY_JSONB;\n            this.jackson = false;\n        } else {\n            throw new IllegalArgumentException(\"Unexpected serializationLibrary value: \" + serializationLibrary);\n        }\n    }\n\n    public void forceSerializationLibrary(String serializationLibrary) {\n        if (this.serializationLibrary != null && !this.serializationLibrary.equalsIgnoreCase(serializationLibrary)) {\n            LOGGER.warn(\"The configured serializationLibrary '{}', is not supported by the library: '{}', switching back to: {}\",\n                    this.serializationLibrary, getLibrary(), serializationLibrary);\n        }\n        setSerializationLibrary(serializationLibrary);\n    }\n\n    @Override\n    public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {\n        generateYAMLSpecFile(objs);\n        return super.postProcessSupportingFileData(objs);\n    }\n\n    @Override","sourceCodeStart":1342,"sourceCodeEnd":1378,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java#L1342-L1378","documentation":"Thrown by JavaClientCodegen.setSerializationLibrary when the serializationLibrary additional property is not one of the Java client generator's supported JSON libraries: 'jackson', 'gson', or 'jsonb' (case-insensitive). The setter is invoked via convertPropertyToStringAndWriteBack(CodegenConstants.SERIALIZATION_LIBRARY, ...) during processOpts, and also directly by user code or the CLI. Any other string is rejected before templates are rendered.","triggerScenarios":"Passing --additional-properties serializationLibrary=moshi (or fastjson, gson-typed, kryo, 'JSON-B' with a stray hyphen) to -g java. Also triggered programmatically via clientCodegen.setSerializationLibrary(\"json-p\") in embedded usage, or when a shared config file written for the Kotlin generator ('serializationLibrary=moshi') is reused for -g java.","commonSituations":"Config files shared across generators: the Kotlin client accepts 'moshi' and 'kotlinx_serialization', so a multi-generator pipeline reuses an incompatible value. Typos like 'jacksom', 'gscon', or 'json-b' (the accepted literal is 'jsonb') are common. Version upgrades also surface this when a previously tolerated value is removed.","solutions":["Change the value to jackson, gson, or jsonb exactly (case-insensitive): --additional-properties serializationLibrary=jsonb","Check the accepted list per generator with `openapi-generator-cli config-help -g java` before reusing configs across language targets","If embedding the generator, validate the string against the three constants before calling setSerializationLibrary","Search your --config JSON and CI templates for a stale serializationLibrary key; the CLI flag and the file both feed the same property"],"exampleFix":"# before\nopenapi-generator-cli generate -g java -i api.yaml \\\n  --additional-properties serializationLibrary=json-b\n\n# after\nopenapi-generator-cli generate -g java -i api.yaml \\\n  --additional-properties serializationLibrary=jsonb","handlingStrategy":"validation","validationCode":"Set<String> ok = Set.of(\"jackson\", \"gson\", \"jsonb\");\nString s = (String) opts.get(\"serializationLibrary\");\nif (s != null && !ok.contains(s.toLowerCase(Locale.ROOT))) {\n    throw new IllegalArgumentException(\"serializationLibrary must be one of \" + ok + \", got: \" + s);\n}","typeGuard":null,"tryCatchPattern":"try {\n    codegen.processOpts();\n} catch (IllegalArgumentException e) {\n    // setSerializationLibrary rejects unknown values before any file is written\n    fail(\"Unsupported serializationLibrary='\" + opts.get(\"serializationLibrary\") + \"' for -g java; use jackson|gson|jsonb\");\n}","preventionTips":["Normalize serializationLibrary to lowercase before injecting it into options","Maintain a per-generator capability matrix (which JSON libs each -g accepts) in your codegen wrapper","Prefer omitting the option to accept the generator default when you have no strong requirement"],"tags":["java","openapi-generator","serialization","jackson","gson","jsonb","configuration","option-validation"],"backgroundTag":"invalid-serialization-library","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}