OpenAPITools/openapi-generator · error · ResponseStatusException

No options were supplied

Error message

No options were supplied

What it means

Thrown by POST /api/gen/clients/{language} and /api/gen/servers/{framework} when the request carries no GeneratorInput at all, i.e. opts == null at Generator.java:78-80. The generator deliberately refuses to guess: even though a spec could theoretically be required later, an entirely missing body/options object is rejected up front with 400 'No options were supplied'. Note that a JSON body of {} will NOT hit this — it fails later at 286 instead.

Source

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

        }

        String getTypeName() {
            return name;
        }
    }

    public static String generateClient(String language, GeneratorInput opts) {
        return generate(language, opts, Type.CLIENT);
    }

    public static String generateServer(String language, GeneratorInput opts) {
        return generate(language, opts, Type.SERVER);
    }

    private static String generate(String language, GeneratorInput opts, Type type) {
        LOGGER.debug(String.format(Locale.ROOT, "generate %s for %s", type.getTypeName(), language));
        if (opts == null) {
            throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "No options were supplied");
        }
        JsonNode node = opts.getSpec();
        if (node != null && "{}".equals(node.toString())) {
            LOGGER.debug("ignoring empty spec");
            node = null;
        }
        OpenAPI openapi;
        ParseOptions parseOptions = new ParseOptions();
        parseOptions.setResolve(true);
        if (node == null) {
            if (opts.getOpenAPIUrl() != null) {
                if (opts.getAuthorizationValue() != null) {
                    List<AuthorizationValue> authorizationValues = new ArrayList<>();
                    authorizationValues.add(opts.getAuthorizationValue());
                    openapi = new OpenAPIParser().readLocation(opts.getOpenAPIUrl(), authorizationValues, parseOptions).getOpenAPI();
                } else {
                    openapi = new OpenAPIParser().readLocation(opts.getOpenAPIUrl(), null, parseOptions).getOpenAPI();
                }

View on GitHub (pinned to fcec517be3)

Solutions

  1. Always send a JSON body with Content-Type: application/json, minimally {"spec": {...}} or {"openAPIUrl": "..."}
  2. In scripts, assert the spec file exists and is non-empty before using -d @spec.json
  3. Passing an empty object is not a workaround — it moves the failure to 'No OpenAPI specification was supplied' (286)

Example fix

# before
curl -s -X POST "$host/api/gen/clients/java" -H 'Content-Type: application/json'   # no body -> 400 No options were supplied

# after
curl -s -X POST "$host/api/gen/clients/java" -H 'Content-Type: application/json' \
  -d "{\"openAPIUrl\":\"https://petstore3.swagger.io/api/v3/openapi.json\"}"
Defensive patterns

Strategy: validation

Validate before calling

// never POST without a body; build the minimum valid input up front
GeneratorInput input = new GeneratorInput();
input.setOpenAPIUrl(specUrl);          // or input.setSpec(specNode)
if (input.getSpec() == null && input.getOpenAPIUrl() == null) {
    throw new IllegalStateException("refusing to POST: nothing to generate from");
}

Type guard

boolean isSubmittable(GeneratorInput in) {
    return in != null
        && (in.getSpec() != null || in.getOpenAPIUrl() != null); // {} spec counts as null server-side
}

Prevention

When it happens

Trigger: POST with no body at all (missing -d in curl, empty fetch body); Content-Type omitted together with an empty body so Spring binds nothing; programmatic calls passing null as the GeneratorInput.

Common situations: Shell scripts where the -d @file.json references a missing/empty file; HTTP clients configured with body: null; copy-pasted curl commands that lost their --data flag; unit tests invoking Generator.generateClient("java", null).

Related errors


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