OpenAPITools/openapi-generator · error · IllegalArgumentException

Library 'spring-http-interface' is only supported with Sprin

Error message

Library 'spring-http-interface' is only supported with Spring Boot 3 or 4

What it means

The spring-http-interface library generates clients built on Spring's declarative HTTP interfaces (@HttpExchange proxies), which exist only in Spring Framework 6 (Boot 3) and later. During supporting-file setup the generator throws when neither useSpringBoot3 nor useSpringBoot4 is enabled, because the required framework APIs are absent from older Boot versions.

Source

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

            } else if (SPRING_BOOT.equals(library)) {
                apiTemplateFiles.put("apiController.mustache", "Controller.java");
                supportingFiles.add(new SupportingFile("application.mustache",
                        ("src.main.resources").replace(".", java.io.File.separator), "application.properties"));
                supportingFiles.add(new SupportingFile("homeController.mustache",
                        (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator),
                        "HomeController.java"));
                supportingFiles.add(new SupportingFile("openapi.mustache",
                        ("src/main/resources").replace("/", java.io.File.separator), "openapi.yaml"));
                if (!reactive && !apiFirst) {
                    if (DocumentationProvider.SPRINGDOC.equals(getDocumentationProvider())) {
                        supportingFiles.add(new SupportingFile("springdocDocumentationConfig.mustache",
                                (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator),
                                "SpringDocConfiguration.java"));
                    }
                }
            } else if (SPRING_HTTP_INTERFACE.equals(library)) {
                if (!(isUseSpringBoot3() || isUseSpringBoot4())) {
                    throw new IllegalArgumentException("Library '" + SPRING_HTTP_INTERFACE + "' is only supported with Spring Boot 3 or 4");
                }

                String httpInterfacesAbstractConfiguratorFile = useHttpServiceProxyFactoryInterfacesConfigurator ?
                    "httpServiceProxyFactoryInterfacesConfigurator.mustache" :
                    "httpInterfacesConfiguration.mustache";

                supportingFiles.add(new SupportingFile(httpInterfacesAbstractConfiguratorFile,
                        (sourceFolder + File.separator + configPackage).replace(".", java.io.File.separator), "HttpInterfacesAbstractConfigurator.java"));

                writePropertyBack(HTTP_INTERFACES_CONFIGURATOR_DEPENDENCY,
                    useHttpServiceProxyFactoryInterfacesConfigurator ?
                    "HttpServiceProxyFactory" :
                    reactive ? "WebClient" : "RestClient"
                );
            }
        }

        if (SPRING_BOOT.equals(library)) {

View on GitHub (pinned to fcec517be3)

Solutions

  1. Add -DuseSpringBoot3=true or -DuseSpringBoot4=true to the generation command.
  2. If you must stay on Spring Boot 2.x, switch to a client library that supports it (resttemplate, webclient).

Example fix

# before
openapi-generator generate -g spring -i api.yaml --library=spring-http-interface

# after
openapi-generator generate -g spring -i api.yaml --library=spring-http-interface -DuseSpringBoot3=true
Defensive patterns

Strategy: validation

Validate before calling

# bash
if [ "$LIBRARY" = "spring-http-interface" ] \
   && [ "$USE_SPRING_BOOT3" != "true" ] && [ "$USE_SPRING_BOOT4" != "true" ]; then
  echo "spring-http-interface requires useSpringBoot3=true or useSpringBoot4=true" >&2; exit 1
fi

Try / catch

// Java
try {
    new DefaultGenerator().opts(input).generate();
} catch (IllegalArgumentException e) {
    // library/version mismatch: set a Boot flag in ClientOptInput and regenerate once
}

Prevention

When it happens

Trigger: -g spring --library=spring-http-interface with neither -DuseSpringBoot3=true nor -DuseSpringBoot4=true.

Common situations: Using the generator defaults (no Boot flag) with this library; Spring Boot 2 projects trying the new client style; the Boot flag getting lost when a config moves from CLI to Maven plugin or between CI jobs.

Related errors


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