{"record":{"id":"a30cc21b3ad1df2a","repo":"OpenAPITools/openapi-generator","slug":"this-library-currently-only-supports-gson-serializ","errorCode":null,"errorMessage":"This library currently only supports gson serialization. Try adding '--additional-properties serializationLibrary=gson' to your command.","messagePattern":"This library currently only supports gson serialization\\. Try adding '--additional-properties serializationLibrary=gson' to your command\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java","lineNumber":749,"sourceCode":"\n        if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {\n            if (!additionalProperties.containsKey(ROOM_MODEL_PACKAGE))\n                this.setRoomModelPackage(packageName + \".models.room\");\n            else\n                this.setRoomModelPackage(additionalProperties.get(ROOM_MODEL_PACKAGE).toString());\n        }\n        additionalProperties.put(ROOM_MODEL_PACKAGE, roomModelPackage);\n\n        supportingFiles.add(new SupportingFile(\"infrastructure/CollectionFormats.kt.mustache\", infrastructureFolder, \"CollectionFormats.kt\"));\n\n        // We have auth related partial files, so they can be overridden, but don't generate them explicitly\n        supportingFiles.add(new SupportingFile(\"request/GsonRequest.mustache\", requestFolder, \"GsonRequest.kt\"));\n        supportingFiles.add(new SupportingFile(\"request/IRequestFactory.mustache\", requestFolder, \"IRequestFactory.kt\"));\n        supportingFiles.add(new SupportingFile(\"request/RequestFactory.mustache\", requestFolder, \"RequestFactory.kt\"));\n        supportingFiles.add(new SupportingFile(\"infrastructure/CollectionFormats.kt.mustache\", infrastructureFolder, \"CollectionFormats.kt\"));\n\n        if (getSerializationLibrary() != SERIALIZATION_LIBRARY_TYPE.gson) {\n            throw new RuntimeException(\"This library currently only supports gson serialization. Try adding '--additional-properties serializationLibrary=gson' to your command.\");\n        }\n        addSupportingSerializerAdapters(infrastructureFolder);\n        supportingFiles.remove(new SupportingFile(\"jvm-common/infrastructure/Serializer.kt.mustache\", infrastructureFolder, \"Serializer.kt\"));\n\n    }\n\n    private void addSupportingSerializerAdapters(final String infrastructureFolder) {\n        supportingFiles.add(new SupportingFile(\"jvm-common/infrastructure/Serializer.kt.mustache\", infrastructureFolder, \"Serializer.kt\"));\n\n        switch (getSerializationLibrary()) {\n            case moshi:\n                if (enumUnknownDefaultCase) {\n                    supportingFiles.add(new SupportingFile(\"jvm-common/infrastructure/SerializerHelper.kt.mustache\", infrastructureFolder, \"SerializerHelper.kt\"));\n                }\n                supportingFiles.add(new SupportingFile(\"jvm-common/infrastructure/ByteArrayAdapter.kt.mustache\", infrastructureFolder, \"ByteArrayAdapter.kt\"));\n                supportingFiles.add(new SupportingFile(\"jvm-common/infrastructure/UUIDAdapter.kt.mustache\", infrastructureFolder, \"UUIDAdapter.kt\"));\n                supportingFiles.add(new SupportingFile(\"jvm-common/infrastructure/LocalDateAdapter.kt.mustache\", infrastructureFolder, \"LocalDateAdapter.kt\"));\n                supportingFiles.add(new SupportingFile(\"jvm-common/infrastructure/LocalDateTimeAdapter.kt.mustache\", infrastructureFolder, \"LocalDateTimeAdapter.kt\"));","sourceCodeStart":731,"sourceCodeEnd":767,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/KotlinClientCodegen.java#L731-L767","documentation":"processJVMVolleyLibrary hard-requires serializationLibrary=gson: the Volley templates (GsonRequest.mustache, RequestFactory.mustache, ...) are built around gson 2.8.9. The generator-wide default serializationLibrary is moshi, so selecting --library=jvm-volley without explicitly setting gson always throws this RuntimeException during library processing. The Volley library is additionally marked Deprecated in supportedLibraries.","triggerScenarios":"`-g kotlin --library=jvm-volley` alone (default moshi → throw); with `-p serializationLibrary=moshi|jackson|kotlinx_serialization` explicitly.","commonSituations":"Legacy Android pipelines still on Volley; copying a kotlin invocation from a colleague who used okhttp4 defaults and just changing --library.","solutions":["Add `-p serializationLibrary=gson` exactly.","Better: migrate off the deprecated jvm-volley library — jvm-okhttp4 (moshi default) is the maintained JVM client path."],"exampleFix":"# before\nopenapi-generator-cli generate -g kotlin --library=jvm-volley -i api.yaml\n# after\nopenapi-generator-cli generate -g kotlin --library=jvm-volley -i api.yaml -p serializationLibrary=gson","handlingStrategy":"validation","validationCode":"# shell: volley demands gson\nif [ \"$LIBRARY\" = \"jvm-volley\" ] && [ \"${SERIALIZATION_LIBRARY:-moshi}\" != \"gson\" ]; then\n  echo \"jvm-volley requires serializationLibrary=gson\" >&2; exit 2\nfi","typeGuard":null,"tryCatchPattern":"try {\n    DefaultGenerator().opts(clientOptInput).generate()\n} catch (e: RuntimeException) {\n    throw IllegalStateException(\"jvm-volley serialization mismatch: ${e.message}\", e)\n}","preventionTips":["Whenever you change --library, re-check which serializationLibrary it demands.","Track that jvm-volley is deprecated; plan migration to jvm-okhttp4.","Encode the library⇒serialization pairing table in your generate script."],"tags":["openapi-generator","kotlin","volley","serialization","configuration"],"backgroundTag":"serialization-library-mismatch","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}