OpenAPITools/openapi-generator · error · ResponseStatusException

Framework is required

Error message

Framework is required

What it means

Thrown by POST /api/gen/servers/{framework} (generateServerForLanguage, GenApiService.java:163-166) when the framework argument is null. Because framework arrives as a Spring path variable it is practically never null over HTTP (a missing segment simply does not route here), so this 400 guard fires mainly on direct/programmatic calls to the delegate or GenApiService, e.g. unit tests or custom controllers that pass a null reference.

Source

Thrown at modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/GenApiService.java:165

        } else {
            return ResponseEntity.notFound().build();
        }
    }

    @Override
    public ResponseEntity<List<String>> clientOptions() {
        return ResponseEntity.ok().body(clients);
    }

    @Override
    public ResponseEntity<List<String>> serverOptions() {
        return ResponseEntity.ok().body(servers);
    }

    @Override
    public ResponseEntity<ResponseCode> generateServerForLanguage(String framework, GeneratorInput generatorInput) {
        if (framework == null) {
            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "Framework is required");
        }
        String filename = Generator.generateServer(framework, generatorInput);
        LOGGER.debug("generated name: {}", filename);

        return getResponse(filename, framework + "-server");
    }

    private ResponseEntity<ResponseCode> getResponse(String filename, String friendlyName) {
        String host = System.getenv("GENERATOR_HOST");

        UriComponentsBuilder uriBuilder;
        if (!StringUtils.isBlank(host)) {
            uriBuilder = UriComponentsBuilder.fromUriString(host);
        } else {
            uriBuilder = ServletUriComponentsBuilder.fromCurrentContextPath();
        }

        if (filename != null) {

View on GitHub (pinned to fcec517be3)

Solutions

  1. Always pass a concrete framework value (e.g. 'spring', 'nodejs-server'); pick from GET /api/gen/servers
  2. If resolving the name dynamically, fail fast on null before calling the API (log which config key is missing)
  3. In tests, use a known-good framework from the servers list instead of a placeholder

Example fix

// before
delegate.generateServerForLanguage(null, input);   // 400 Framework is required

// after
if (framework == null || framework.isBlank()) throw new IllegalArgumentException("framework not configured");
delegate.generateServerForLanguage(framework, input);
Defensive patterns

Strategy: validation

Validate before calling

// resolve and assert the framework before calling
String framework = config.get("serverFramework");
if (framework == null || framework.isBlank()) {
    throw new IllegalArgumentException("serverFramework missing in config; pick from GET /api/gen/servers");
}

Type guard

private static final Set<String> SERVERS = Set.copyOf(fetch("/api/gen/servers"));

boolean isSupportedFramework(String f) {
    return f != null && SERVERS.contains(f);
}

Prevention

When it happens

Trigger: Calling genApiService.generateServerForLanguage(null, input) directly in code or tests; a custom wrapper/controller that resolves the framework from a query param or map lookup that returned null; reflection-based invocation without the argument.

Common situations: Writing integration tests against the delegate and forgetting to set the framework; wrapper services that look up framework from configuration (missing config key yields null); code ported from the clients endpoint where language was validated elsewhere.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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