{"record":{"id":"eb7cb6290557bdd2","repo":"OpenAPITools/openapi-generator","slug":"invalid-http-library-getlibrary-only-ht","errorCode":null,"errorMessage":"Invalid HTTP library \" + getLibrary() + \". Only httr, httr2 are supported.","messagePattern":"Invalid HTTP library \" \\+ getLibrary\\(\\) \\+ \"\\. Only httr, httr2 are supported\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java","lineNumber":348,"sourceCode":"        supportingFiles.add(new SupportingFile(\"ApiResponse.mustache\", File.separator + \"R\", \"api_response.R\"));\n        supportingFiles.add(new SupportingFile(\"api_client.mustache\", File.separator + \"R\", \"api_client.R\"));\n        supportingFiles.add(new SupportingFile(\"NAMESPACE.mustache\", \"\", \"NAMESPACE\"));\n        supportingFiles.add(new SupportingFile(\"testthat.mustache\", File.separator + \"tests\", \"testthat.R\"));\n        supportingFiles.add(new SupportingFile(\"r-client.mustache\", File.separator + \".github\" + File.separator + \"workflows\", \"r-client.yaml\"));\n        supportingFiles.add(new SupportingFile(\"lintr.mustache\", \"\", \".lintr\"));\n\n        if (HTTR.equals(getLibrary())) {\n            // for httr\n            setLibrary(HTTR);\n        } else if (HTTR2.equals(getLibrary())) {\n            // for httr2\n            setLibrary(HTTR2);\n            additionalProperties.put(\"isHttr2\", Boolean.TRUE);\n            if (generateWrapper) { // generateWrapper option only supports in httr2 library\n                supportingFiles.add(new SupportingFile(\"api_wrapper.mustache\", \"R\", packageName.toLowerCase(Locale.ROOT) + \"_api.R\"));\n            }\n        } else {\n            throw new IllegalArgumentException(\"Invalid HTTP library \" + getLibrary() + \". Only httr, httr2 are supported.\");\n        }\n\n        // add lambda for mustache templates to fix license field\n        additionalProperties.put(\"lambdaLicense\", new Mustache.Lambda() {\n            @Override\n            public void execute(Template.Fragment fragment, Writer writer) throws IOException {\n                String content = fragment.execute();\n                content = content.trim().replace(\"Apache-2.0\", \"Apache License 2.0\");\n                writer.write(content);\n            }\n        });\n\n        // add lambda for mustache templates to escape %\n        additionalProperties.put(\"lambdaRdocEscape\", new Mustache.Lambda() {\n            @Override\n            public void execute(Template.Fragment fragment, Writer writer) throws IOException {\n                String content = fragment.execute();\n                content = content.trim().replace(\"%\", \"\\\\%\");","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/OpenAPITools/openapi-generator/blob/fcec517be3cf5b7964296bcba25fbc97541484e7/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RClientCodegen.java#L330-L366","documentation":"The R client generator supports exactly two HTTP libraries: httr and httr2. In processOpts() the library value selects template branches (httr2 additionally enables the generateWrapper option and the *_api.R wrapper); any other -l/--library value falls into the else branch and throws IllegalArgumentException listing the supported values.","triggerScenarios":"openapi-generator-cli generate -i api.yaml -g r -l curl / -l httr3 / -l restifts; also setting <library> in the Maven plugin to a value copied from another generator's docs.","commonSituations":"Copy-pasting a -l flag from a python or java example into an R job; assuming the library flag is free-form; typos like httr2-client. The flag is also case-sensitive: HTTR vs httr are compared exactly.","solutions":["Use -l httr or -l httr2 (exact lowercase)","Omit -l entirely to take the generator default instead of guessing a value","If you need the wrapper API, use -l httr2 together with -c generateWrapper=true (wrapper is httr2-only)"],"exampleFix":"# before\nopenapi-generator-cli generate -i api.yaml -g r -l httr3\n# after\nopenapi-generator-cli generate -i api.yaml -g r -l httr2 -c generateWrapper=true","handlingStrategy":"validation","validationCode":"# bash: whitelist the library before generating\nR_LIBS='httr httr2'\n[[ \" ${R_LIBS} \" == *\" ${R_LIBRARY:-httr} \"* ]] || { echo \"-l must be one of: ${R_LIBS}\"; exit 1; }\nopenapi-generator-cli generate -i api.yaml -g r -l \"${R_LIBRARY:-httr}\"","typeGuard":null,"tryCatchPattern":"try {\n    RClientCodegen codegen = new RClientCodegen();\n    codegen.setLibrary(\"httr2\"); // or leave default\n    new DefaultGenerator().opts(new ClientOptInput().opts(codegen)).generate();\n} catch (IllegalArgumentException e) {\n    // 'Invalid HTTP library ...' - only httr and httr2 are valid; fix and rerun\n}","preventionTips":["Pin -l httr or -l httr2 explicitly in CI instead of templating from other generators","Remember generateWrapper only works with httr2","Omit -l to fall back to the generator default when unsure"],"tags":["r","codegen","configuration","http-library","openapi-generator"],"backgroundTag":"unsupported-library-option","analyzedSha":"fcec517be3cf5b7964296bcba25fbc97541484e7","analyzedAt":"2026-08-22T11:13:11.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}