OpenAPITools/openapi-generator · error · RuntimeException

Please report the issue as the parameter name cannot be null

Error message

Please report the issue as the parameter name cannot be null: %s

What it means

AbstractPythonConnexionServerCodegen renames spec parameters that are not valid Python identifiers. After dereferencing $refs it reads parameter.getName(); if the name is null it throws RuntimeException('Please report the issue as the parameter name cannot be null'). A null name means the spec (or the resolved $ref target) supplied a parameter object with no 'name' key — the generator assumes one exists on every parameter object.

Solutions

  1. Add an explicit name to every parameter in the failing operation (the surrounding loop's pathname identifies the path item)
  2. Validate with a strict linter (Spectral oas3 rules, swagger-cli validate) and fix every 'parameter must have a name' error before generating
  3. If the spec validates clean and it still throws, upgrade openapi-generator and report the issue with the operation

Example fix

# before
parameters:
  - in: query
    schema:
      type: string

# after
parameters:
  - name: q
    in: query
    schema:
      type: string
Defensive patterns

Strategy: validation

Validate before calling

// JS: every parameter object (incl. resolved refs) must have a non-null name
const components = (spec.components && spec.components.parameters) || {};
function hasName(p) { return p && p.name != null; }
for (const item of Object.values(spec.paths || {})) {
  for (const op of Object.values(item)) {
    for (const p of (op && op.parameters) || []) {
      const resolved = p.$ref ? components[p.$ref.split('/').pop()] : p;
      if (!hasName(resolved)) fail('parameter without name');
    }
  }
}

Try / catch

try { generator.generate(); } catch (RuntimeException e) { if (String.valueOf(e.getMessage()).contains("parameter name cannot be null")) { /* find the parameter missing 'name' in the printed operation */ } throw e; }

Prevention

When it happens

Trigger: A parameter object missing the required 'name' field, e.g. { in: query, schema: { type: string } }, or a $ref pointing at a component that lacks name. An empty-string name only logs an error later, it does not throw; null is what raises this. Note this.toParamName is called before the null check, so some builds NPE first — same root cause.

Common situations: Hand-written specs; exporters/refactoring tools that drop 'name'; specs that slip past lenient 3.1 parsing; operations generated from templates with unfilled name fields.

Related errors


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

Appendix: source

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

                            tag = operation.getTags().get(0);
                        }
                        String operationId = getOrGenerateOperationId(operation, pathname, method.toString());
                        operation.setOperationId(toOperationId(operationId));
                        if (operation.getExtensions() == null || operation.getExtensions().get("x-openapi-router-controller") == null) {
                            operation.addExtension(
                                    "x-openapi-router-controller",
                                    controllerPackage + "." + toApiFilename(tag)
                            );
                        }
                        if (operation.getParameters() != null) {
                            for (Parameter parameter : operation.getParameters()) {
                                if (StringUtils.isNotEmpty(parameter.get$ref())) {
                                    parameter = ModelUtils.getReferencedParameter(openAPI, parameter);
                                }
                                String swaggerParameterName = parameter.getName();
                                String pythonParameterName = this.toParamName(swaggerParameterName);
                                if (swaggerParameterName == null) {
                                    throw new RuntimeException("Please report the issue as the parameter name cannot be null: " + parameter);
                                }
                                if (!swaggerParameterName.equals(pythonParameterName)) {
                                    LOGGER.warn(
                                            "Parameter name '{}' is not consistent with Python variable names. It will be replaced by '{}'",
                                            swaggerParameterName, pythonParameterName);
                                    parameter.addExtension("x-python-connexion-openapi-name", swaggerParameterName);
                                    parameter.setName(pythonParameterName);
                                }
                                if (swaggerParameterName.isEmpty()) {
                                    LOGGER.error("Missing parameter name in {}.{}", pathname, parameter.getIn());
                                }
                            }
                        }
                        RequestBody body = operation.getRequestBody();
                        if (fixBodyName && body != null) {
                            if (body.getExtensions() == null || !body.getExtensions().containsKey("x-body-name")) {
                                String bodyParameterName = "body";
                                if (operation.getExtensions() != null && operation.getExtensions().containsKey("x-codegen-request-body-name")) {

View on GitHub (pinned to fcec517be3)