OpenAPITools/openapi-generator · error · IllegalArgumentException

Invalid HTTP library " + getLibrary() + ". Only faraday, typ

Error message

Invalid HTTP library " + getLibrary() + ". Only faraday, typhoeus and httpx are supported.

What it means

The Ruby client generator supports exactly three HTTP libraries: faraday, typhoeus, and httpx. processOpts() sets an isTyphoeus/isFaraday/isHttpx template flag for the matching value and throws IllegalArgumentException for anything else, so the templates always have exactly one HTTP adapter selected.

Source

Thrown at modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RubyClientCodegen.java:304

        supportingFiles.add(new SupportingFile("Gemfile.mustache", "", "Gemfile"));
        supportingFiles.add(new SupportingFile("rubocop.mustache", "", ".rubocop.yml"));
        supportingFiles.add(new SupportingFile("travis.mustache", "", ".travis.yml"));
        supportingFiles.add(new SupportingFile("gitlab-ci.mustache", "", ".gitlab-ci.yml"));
        supportingFiles.add(new SupportingFile("gemspec.mustache", "", gemName + ".gemspec"));
        supportingFiles.add(new SupportingFile("configuration.mustache", gemFolder, "configuration.rb"));
        supportingFiles.add(new SupportingFile("api_client.mustache", gemFolder, "api_client.rb"));

        if (TYPHOEUS.equals(getLibrary())) {
            // for Typhoeus
            additionalProperties.put("isTyphoeus", Boolean.TRUE);
        } else if (FARADAY.equals(getLibrary())) {
            // for Faraday
            additionalProperties.put("isFaraday", Boolean.TRUE);
        } else if (HTTPX.equals(getLibrary())) {
            // for Faraday
            additionalProperties.put("isHttpx", Boolean.TRUE);
        } else {
            throw new IllegalArgumentException("Invalid HTTP library " + getLibrary() + ". Only faraday, typhoeus and httpx are supported.");
        }

        // test files should not be overwritten
        supportingFiles.add(new SupportingFile("rspec.mustache", "", ".rspec")
                .doNotOverwrite());
        supportingFiles.add(new SupportingFile("spec_helper.mustache", specFolder, "spec_helper.rb")
                .doNotOverwrite());

        // add lambda to convert a symbol to a string if an underscore is included (e.g. :'user_uuid' => 'user_uuid')
        additionalProperties.put("lambdaFixHeaderKey", new Mustache.Lambda() {
            @Override
            public void execute(Template.Fragment fragment, Writer writer) throws IOException {
                String content = fragment.execute();
                if (content.contains("_")) {
                    content = content.substring(1);
                }
                writer.write(content);
            }

View on GitHub (pinned to fcec517be3)

Solutions

  1. Use exactly -l faraday, -l typhoeus, or -l httpx
  2. Omit -l to use the generator default
  3. Pick faraday unless you specifically need typhoeus or httpx features

Example fix

# before
openapi-generator-cli generate -i api.yaml -g ruby -l net-http
# after
openapi-generator-cli generate -i api.yaml -g ruby -l faraday
Defensive patterns

Strategy: validation

Validate before calling

# bash: whitelist the library before generating
RUBY_LIBS='faraday typhoeus httpx'
[[ " ${RUBY_LIBS} " == *" ${RUBY_LIBRARY:-faraday} "* ]] || { echo "-l must be one of: ${RUBY_LIBS}"; exit 1; }
openapi-generator-cli generate -i api.yaml -g ruby -l "${RUBY_LIBRARY:-faraday}"

Try / catch

try {
    RubyClientCodegen codegen = new RubyClientCodegen();
    codegen.setLibrary("faraday");
    new DefaultGenerator().opts(new ClientOptInput().opts(codegen)).generate();
} catch (IllegalArgumentException e) {
    // 'Invalid HTTP library ...' - only faraday, typhoeus, httpx; fix and rerun
}

Prevention

When it happens

Trigger: openapi-generator-cli generate -i api.yaml -g ruby -l net-http / -l faraday_middleware / -l Faraday. Comparison is exact/lowercase; capitalization or underscores fail.

Common situations: Assuming any Ruby HTTP gem name works; copy-pasting a -l value from java/python docs; upgrading from older generator versions where fewer libraries existed and scripts pinned an invalid default like 'typhoeus-faraday'.

Related errors


AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22). Data as JSON: /api/errors/e1ca6c9bcd066c1c. Report an issue: GitHub.