OpenAPITools/openapi-generator · error · ResponseStatusException
No OpenAPI specification was supplied
Error message
No OpenAPI specification was supplied
What it means
Thrown by the generate endpoints when a GeneratorInput was supplied but contains neither a usable spec nor an openAPIUrl (Generator.java:89-100). A spec that is exactly {} is explicitly normalized to null ('ignoring empty spec', Generator.java:82-85), so it counts as absent too. The service needs exactly one source of truth — inline spec or remote URL — and refuses to generate from options alone.
Source
Thrown at modules/openapi-generator-online/src/main/java/org/openapitools/codegen/online/service/Generator.java:99
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();
}
} else {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "No OpenAPI specification was supplied");
}
} else if (opts.getAuthorizationValue() != null) {
List<AuthorizationValue> authorizationValues = new ArrayList<>();
authorizationValues.add(opts.getAuthorizationValue());
openapi = new OpenAPIParser().readContents(node.toString(), authorizationValues, parseOptions).getOpenAPI();
} else {
openapi = new OpenAPIParser().readContents(node.toString(), null, parseOptions).getOpenAPI();
}
if (openapi == null) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "The OpenAPI specification supplied was not valid");
}
// do not use opts.getOptions().get("outputFolder") as the input can contain ../../
// to access other folders in the server
String destPath = language + "-" + type.getTypeName();
View on GitHub (pinned to fcec517be3)
Solutions
- Include exactly one of {"spec": {...}} or {"openAPIUrl": "https://..."} in the request body
- Check field spelling: the model expects 'spec' and 'openAPIUrl' — verify with a serialized sample request
- Don't send an empty {} spec; if you have no local spec, pass the URL where it is published
Example fix
// before
GeneratorInput in = new GeneratorInput();
in.setOptions(Map.of("packageName", "com.acme")); // no spec, no url -> 400
// after
GeneratorInput in = new GeneratorInput();
in.setOpenAPIUrl("https://petstore3.swagger.io/api/v3/openapi.json");
in.setOptions(Map.of("packageName", "com.acme")); Defensive patterns
Strategy: validation
Validate before calling
// require exactly one spec source before sending
boolean hasSpec = input.getSpec() != null && !"{}".equals(input.getSpec().toString());
boolean hasUrl = input.getOpenAPIUrl() != null;
if (!hasSpec && !hasUrl) throw new IllegalArgumentException("supply spec or openAPIUrl"); Type guard
boolean hasSpecSource(GeneratorInput in) {
if (in == null) return false;
JsonNode s = in.getSpec();
return (s != null && !s.isNull() && !s.isEmpty()) || in.getOpenAPIUrl() != null;
} Prevention
- Spell fields exactly 'spec' and 'openAPIUrl' (verify your serialized JSON)
- Remember an empty {} spec is treated as absent by the server
When it happens
Trigger: Body {"options":{...}} with no spec/openAPIUrl keys; body {} sent just to satisfy 285; spec sent as the literal string "{}" or an empty JSON object; openAPIUrl key misspelled (e.g. openApiUrl, openapiUrl) so Jackson drops it.
Common situations: Clients that build the request from optional config maps where both fields ended up unset; serialization bugs (wrong field name casing) silently dropping the URL; UIs with two inputs where the user filled neither.
Related errors
- The OpenAPI specification supplied was not valid
- Framework is required
- No options were supplied
- Unsupported target " + language + " supplied
- In rule: " + rule + "the operands were not provided in the f
AI-assisted analysis of OpenAPITools/openapi-generator@fcec517be3 (2026-08-22).
Data as JSON: /api/errors/23aef1a4a2058828.
Report an issue: GitHub.